Google News
logo
Java Unconditional Control Statements
break Statement:
A break statement terminates the execution of the loop and the control is transferred to the statement immediately following the loop. i.e., the break statement is used to terminate loops 
Java Images
break means stop the execution come out of loop.
class Test 
{ 
public static void main(String[] args) 
{ 
for (int i=0;i<10;i++) 
{ 
if (i==5) 
{ 
break; 
} 
System.out.println(i); 
} 
} 
}
Output :
output:1,,2,,3,,4
2. The continue Statement
The continue statement is used to bypass the remainder of the current pass through a loop.

The loop does not terminate when a continue statement is encountered. Instead, the remaining loop statements are skipped and the computation proceeds directly to the next pass through the loop.
Java Images
continue program
class Test 
{ 
public static void main(String[] args) 
{ 
for (int i=0;i<10;i++) 
{ 
if (i==5) 
{ 
continue; 
} 
System.out.println(i); 
} 
} 
}
Output :
0,1,2,3,4,6,7,8,9