YogenGhodke
6/14/2019 - 9:17 AM

break statements to break outer loops

Goto Alternative

outer: for(int i = 0; i<3; i++)
    {
	   System.out.println("l1 = " + i);
	   for(int j = 0; j<5; j++)
	        {
	             if(j==3) break outer;	
	             System.out.println("l2 = " + j); 
	        }
	} 
	
// Directly Breaks outer loop instead of current loop
// O/P : 0 0 1 2
// In case of simple break: O/P : 0 0 1 2 1 0 1 2 2 0 1 2