The break
statement ends a loop (like for
, while
) or the evaluation of a switch statement.
Loop:
while(true) {
if(someCondition == 5) {
break;
}
}
The loop in the example would run forever. But when someCondition
equals 5
at some point of execution, then the loop ends.
If multiple loops are cascaded, only the most inner loop ends using break
.