Understanding continue in Java


continue skips the current iteration of a loop and proceeds to the next iteration.

Source Code

public class ContinueExample {
    public static void main(String[] args) {
        for (int i = 1; i <= 10; i++) {
            if (i == 6) {
                continue;
            }
            System.out.println("i: " + i);
        }
    }
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments