Java Reference
In-Depth Information
System.out.print( a );
System.out.print("\n");
}
}
}
Output:
10
20
30
As the value of a is equal to 40 , the break statement executes and terminates the loop.
Continue Keyword
Continue keyword can be used in any loop structure for deciding the execution control.
When continue is used in for loop then the control is immediately transferred to
the update statement without executing the statements after continue.
In case of while or do-while, control is immediately transferred to the Boolean
expression without executing the statements after continue.
Example:
public class Continue {
public static void main(String args[]) {
int [] values = {10, 20, 30, 40, 50};
for ( int a : values ) {
if( a == 40) {
continue;