Java Break Keyword Example


Whenever there is a break statement inside a loop. It will jump out of the loop, which means breaking the current flow of the loop at a specified condition where the break statement found.

Program
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); } } }
Input
Output