The break statement is a statement composed of the keyword break plus a semicolon. The break statement can be used in the loop body.
In a loop, if the break statement is executed in a certain loop, the entire loop statement ends.
Example:
publicclassMain{publicstaticvoidmain(String[]args){for(inta=1;a<10;a=a+1){if(a%2==0){break;}System.out.print(a);System .out.print(n);}}}
The running results are as follows:
1