Java – Continue statement

PREV     NEXT

  • Java Continue statement skips the current iteration of the loop and evaluates the loop’s condition for the next iteration. Rest of the statements of the loop after the continue statement is not executed and the next iteration is followed.
  • The difference between break and continue is that continue statement breaks the current iteration of the loop,whereas break statement terminates the loop itself.

Syntax For Java Continue Statement:

The syntax of a Java continue statement is given below.

Example For Continue statement in  Java :



Output:

1

3

5

7

9

In the above program, whenever the value of i is divisible by 2 (even number) the current iteration is ignored printing just the odd numbers alone.

PREV     NEXT




Like it? Please Spread the word!