1.break: Jump out of the current loop and continue execution of the statement below the loop body;
2.break+ marking: Jumping out of the current loop and jumping out of the circle indicated by the label;
3.continue: Jump out of this cycle, continue to execute the loop body;
4.continue+ marking: Jump out of this cycle, and point to the position of the label, that is, once again executed in the label statement;
5. The label must be in front of a loop, and there can be no statement behind the line;
6.java with the marking of break, continue, similar to the use of Goto;
7. Put a simple example:
Package Pak;
Import java.io.*;
public class Printmenu {
public static void Main (String args[]) {
InputStreamReader ir=new InputStreamReader (system.in);
BufferedReader br=new BufferedReader (IR);
int select=0;
No1:while (True) {
System.out.println ("====================");
System.out.println ("1. Add");
System.out.println ("2. Modify");
System.out.println ("3. Delete");
System.out.println ("4. Enquiry");
System.out.println ("5. Exit");
System.out.println ("====================");
SYSTEM.OUT.PRINTLN ("Please select Menu function:");
try {
Select=integer.parseint (Br.readline ());
} catch (Exception e) {
Todo:handle exception
}
if (select<1 | | select>5) {
System.out.println ("The feature you have selected does not exist, please re-select!") ");
Continue
}
Switch (SELECT) {
Case 1:
System.out.println ("The feature you have selected is new! ");
Break
Case 2:
System.out.println ("The feature you have selected is modified!") ");
Break
Case 3:
System.out.println ("The feature you have selected is deleted!") ");
Break
Case 4:
SYSTEM.OUT.PRINTLN ("The function you choose is query!") ");
Break
Default
System.out.println ("The feature you chose is to exit!") ");
Break No1;
}
}
}
}
8. Part of their own understanding, partial reprint, link site: http://www.cnblogs.com/ycoe/archive/2006/06/02/415825.aspx;http://tech.ccidnet.com/art/ 3741/20050922/533987_1.html
4 ways to interrupt loops in Java, and some questions about labeling