5. Branching Structures

5.1. Continue Statement

Skips the current iteration of a loop and proceeds to the next iteration.

Example:

public class ContinueExample {

    public static void main(String[] args) {

        for (int i = 1; i <= 5; i++) {

            if (i == 3) {

                continue; // Skips i == 3

            }

            System.out.println("i: " + i);

        }

        // Output:

        // i: 1

        // i: 2

        // i: 4

        // i: 5

    }

}

Notes:

Only skips the current iteration; the loop continues.

Labeled continue: Skips to the next iteration of a specific outer loop (rarely used).