Break:
Berak statements are usually used in loop statements and switch statements, and when the break statement is used in a do-while, for, and while Loop statement, the program terminates the statement following the loop. Usually the break statement is always linked to the if statement, which jumps out of the loop when the condition is met
Continue:
The purpose of the continue statement is to skip a loop and subsequent statements for the next loop. Continue statements are used only in loop bodies such as for, while, Do-while, and often with an if condition statement to speed up the loop
For example: int i=0;
int a=2;
for (i=0;i<10;i++) {
if (i==a) {
①break;
②continue;
}
System.out.print ("Apple");
}
In the example above, if it is ①, then the loop statement executes 3 times, outputs two apple; if it is ②, the loop executes 10 times and outputs 10 apple
Attention:
1) The break statement does not work for if-else conditional statements.
2) in a multi-layer loop, a break statement jumps out only one layer
Shell-jump out of the loop break and continue