Java – Continue statement

PREV     NEXT

  • 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.

Example:

COMPILE & RUN

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

Share this website !!!
Facebook Twitter Linkedin