Java Language Basic Control Structures Break


The break statement ends a loop (like for, while) or the evaluation of a switch statement.


while(true) {
   if(someCondition == 5) {

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.