Continue Statement in Java
What is continue statement in Java?
continue statement in Java is a Jumping statement, when continue is encountered in loop, the control immediately jumps to the next iteration. In can be used in any kind of loop.
Syntax of continue statement.
continue;
Example of continue statement in Java:
// Java program of continue statement
public class ContinueStatement {
public static void main(String[] args) {
int i;
for(i=1;i<=5;i++)
{
if(i==3)
{
continue;
} //end of if
System.out.println("i is = "+i);
} //end of for loop
}//end of main method
}//end of class ContinueStatement
Output:
i is = 2
i is = 4
i is = 5
In the above example, you can notice that for loop executed 4 times, because when continue statement is encountered the control immediately jumped for the next iteration of for loop, skipping to print the statement third time.