|
Instant eXpert Guides |
A few definitions from Webster's 1828 dictionary are helpful here:
Examples of usage:
After the hurricane had destroyed the city, the gentlemen mutually agreed to break the contract.
Danny used a crowbar to break the bulldog's tenacious grip on the man's leg.
The Mafia gangster said he would break every bone in my body if I did not give him $1 Million.
A Java program branching statement that is designed to interrupt (or break out of) an iterative looping mechanism, like for, while, or do-while. The program is instructed to stop evaluation (of the looping statement) and to resume program execution at the statement immediately following the current looping statement. Another use of break is in combination with switch, to stop evaluating case statements (after one is found true), and branch to code immediately following the switch.
There are labeled breaks, or simple (un-labeled) breaks. If the break is followed by a label, the program will resume execution at the point it exits the labeled statement. The most common use is a simple break:
while (contract is good) {
...
...
if (hurricane destroys Galveston) {
// contract is null and void
break;
}
}
A real Java example of simple (un-labled) break from looping.
Insert example here...
A real Java example of labeled break from loop within another loop.
Insert example here...
A real Java example of break from switch cases.
Insert example here...
branching statements, break - Sun Java documentation
Java Reserved Words - Instant Expert Guide