Java - Decision Control and looping statement - break Tutorial
Whenever there is a break statement inside a loop. It will jump out of the loop,which means breaking the current flow of loop at a specified condition where break statement found.
public class BreakExample {
public static void main(String[] args) {
//using for loop
for(int i=0;i<=5;i++){
if(i==3){
//breaking the loop
break;
}
System.out.println(i);
}
}
}
In above example
Break statement found when the i=3,so at this point it will terminate all the iteration after i=3.