To put it simply, for example, a program like this:
For (...) {
...
Continue/break;
...
}
System.out.prinln ("a");
Continue means to execute "for (...)" immediately. This line of code, break means to immediately execute "SYSTEM.OUT.PRINLN (" a ");" This line of code.
Run break directly ends the for loop
Run continue directly to the next loop
The following code example
Package Java_test;public class Breaktest {public static void main (String args[]) {System.out.println ("loop does not start"); System.out.println ("Start test continue now"); for (int i = 0; i < 3; i++) {System.out.println ("start" + i + "secondary for Loop"); if (i = = 1) {continue;} System.out.println ("Look at continue after the execution here?" ");} SYSTEM.OUT.PRINTLN ("Continue test completed \n***********************"); System.out.println ("Start Test break Now"), for (int i = 0; i < 3; i++) {System.out.println ("start" + i + "secondary for Loop"); if (i = = 1) {bre AK;} System.out.println ("Look at the break after it's done here?") ");} SYSTEM.OUT.PRINTLN ("Break test completed \n***********************");}}
Operation Result:
Loop does not start
Start testing Continue now
Start the No. 0 time for Loop
Have you seen continue here?
Start the 1th time for loop
Start the 2nd time for loop
Have you seen continue here?
Continue test complete.
***********************
Start Test break now
Start the No. 0 time for Loop
See if it's done here after break?
Start the 1th time for loop
Break Test complete
***********************
Java Foundation _break and Contiune usage