Break

A **__break__** method is used to exit a code. A break method is used in //switch// statement, and also, it can be used to exit a //while, for,// or //do// loop. For example, the break statement in the following loop terminates the loop when the end of input is reached. code while (true) {  String input = JOptionPane.showInputDialog("Enter value, Cancel to quit"); if(input == null) // leave loop in the middle **break**; double x = Double.parseDouble(input); data.add(x) } code In java, there is a second form of the **break** statement that is used to break out of a nested statement. The statement statements) can be tagged with a lavel---the syntax is label: statement The labeled break statement was invented to break out of a set of nested loops.
 * " //break label;//** " immediately jumps to the end of the statment that is tagged with a label. Any statement (including if and block

code outerloop: while(outer loop condition) {  **. . .**   while(inner loop condition) {  **. . .**      if(something really bad happened) break outerloop; } } //jumps here if something really bad happened//

code