continue

A statement that skips the rest of the current loop repetition.

What does continue do in Java?

continue — A statement that skips the rest of the current loop repetition.

class NumberFinder {
    int firstOddNumber(int[] numbers) {
        for (int number : numbers) {
            if (number % 2 == 0) {
                continue;
            }

            return number;
        }

        return -1;
    }
}

Level: Apprentice · More Java terms at this level

Updated

In other subjects