Java - Statement continue Statement

What is continue Statement?

A continue statement can only be used inside the for-loop, while-loop, and do-while statements.

There are two forms of the continue Statements:

  • Unlabeled continue statement
  • Labeled continue statement

An example of an unlabeled continue statement is

continue;

An example of a labeled continue statement is

continue label;

A continue statement skips the current loop iteration.

Example

Demo

public class Main {
  public static void main(String[] args) {
    for (int i = 1; i < 10; i++) {
      if (i % 2 == 0) {
        continue;
      }//  w  w  w. jav  a2  s  .  com
      System.out.println(i);
    }
  }
}

Result

Related Topics