The continue Keyword in Java


The continue keyword skips the current iteration of a loop and continues with the next iteration.

Source Code

for (int i = 0; i < 10; i++) {
    if (i == 5) {
        continue; // Skips the rest of the loop body when i is 5
    }
    System.out.println(i);
}

Use continue to skip specific iterations of a loop based on a condition.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments