The continue Statement : Continue Statement « Statement Control « Java Tutorial






The continue statement stops the execution of the current iteration and causes control to begin with the next iteration.

For example, the following code prints the number 0 to 9, except 5.

public class MainClass {

  public static void main(String[] args) {
    for (int i = 0; i < 10; i++) {
      if (i == 5) {
        continue;
      }
      System.out.println(i);
    }
  }

}








4.9.Continue Statement
4.9.1.The continue Statement
4.9.2.The continue statement: skips all or part of a loop iteration
4.9.3.The Labeled continue statement
4.9.4.Calculating Primes: using continue statement and label