The break statement has a very simple syntax:
break;
This statement is valid only within the body of a while, for, or for/in loop. Using it outside of a loop is a syntax error. When executed, the break statement exits the currently running loop. This statement is usually used to exit a loop prematurely when, for whatever reason (perhaps when an error condition arises), there is no longer any need to complete the loop. The following example searches the elements of an array for a particular value. If the value is found, a break statement terminates the loop:
for(i =index.html 0; i < a.length; i++) { if (a[i] == target) break; }
file: /Techref/language/JAVA/script/definitive/ch05_07.htm, 3KB, , updated: 2019/10/14 15:00, local time: 2024/12/12 07:09,
18.116.37.198:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://sxlist.com/Techref/language/JAVA/script/definitive/ch05_07.htm"> [Chapter 5] 5.7 break</A> |
Did you find what you needed? |
Welcome to sxlist.com!sales, advertizing, & kind contributors just like you! Please don't rip/copy (here's why Copies of the site on CD are available at minimal cost. |
Welcome to sxlist.com! |
.