GoTo Next Iteration in For Loop in java

user1277170 picture user1277170 · Jun 22, 2012 · Viewed 246.5k times · Source

Is there a token in java that skips the rest of the for loop? Something like VB's Continue in java.

Answer

Jigar Joshi picture Jigar Joshi · Jun 22, 2012
continue;

continue; key word would start the next iteration upon invocation

For Example

for(int i= 0 ; i < 5; i++){
 if(i==2){
  continue;
 }
System.out.print(i);
}

This will print

0134

See