Java – Continue Statement

download sourcecode here

The Java continue statement is used to continue loop. It continues the current flow of the program and skips the remaining code at specified condition. In case of inner loop, it continues only inner loop.

Syntax:

  1. jump-statement;
  2. continue;

Java Continue Statement Example

Example:

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

Output:

1
2
3
4
6
7
8
9
10

Leave a Reply

Your email address will not be published. Required fields are marked *