The continue keyword can be used in any of Java’s loop structures to skip the current iteration of the loop and proceed to the next iteration.
Source Code
for (int i = 1; i <= 10; i++) {
if (i % 2 == 0) {
continue; // Skip the rest of the loop body for even numbers
}
System.out.println(i); // This line will only execute for odd numbers
}
Use continue to skip specific loop iterations based on a condition without exiting the loop entirely.