IX Dude - Instant eXpert Guides - Geek with pocket protector Instant eXpert Guides

break - Java key word

break statement, definition, and example

1. Definition of 'break' as commonly used in English
2. Definition of 'break' Java key word
3. Java Programming Example
4. See also

1. Definition of 'break' as commonly used in English

A few definitions from Webster's 1828 dictionary are helpful here:

  1. To part or divide by force and violence; to open by force
  2. To divide by piercing or penetrating;
  3. To discard, dismiss
  4. To violate, as a contract or promise, either by a positive act contrary to the promise, or by neglect or non-fulfilment.
  5. To infringe or violate, as a law, or any moral obligation, either by a positive act or by an omission of what is required.

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.

2. Definition of 'break' Java key word

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;
}
}

3. Java Programming Example

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...

4. See also

branching statements, break - Sun Java documentation

Java Reserved Words - Instant Expert Guide



Created with ixDoc - 24-Sep-2005/7:08:24 :: Jump to Index page - Instant Expert Guides

Copyright © 2005, IX Publishing, Inc. - All rights reserved.