Java Continue Statement

Java Continue Statement ?

Continue statement is used to skip the remaining statement in the loop. The general format is:continue;
Continue is also a loop control statement just like the break statement. continue statement is opposite to break statement where in, Continue statement forces to execute the next iteration of the loop instead of terminating the loop.

In real practice, Continue statement is almost always used inside the body of conditional statement (if...else) inside the loop.

Basically Continue statements are used in the situations when we are not sure about the actual number of iterations for the loop or we want to terminate the loop based on some condition.

Example 1:



Output :

0 1 2 3 5 6

Example 2:



Output :

1 1
1 2
1 3
2 1
2 3
3 1
3 2
3 3