Break Statement In Java

The break statement is used to terminate the loop immediately and the program continues from the next statement.

class Break1 
{  
public static void main(String[] args)
{  
for(int i=1;i<=10;i++)
{  
if(i==5)
{
break;  
}  
System.out.println(i);  
}  
}  
} 
Output:
1
2
3
4

 

Leave a Reply