Skip to content
CampusEduX

Control Flow · Lesson 34 of 150

continue

The continue statement skips the rest of the current loop iteration and jumps straight to the next one, without exiting the loop entirely.

1 min read

01What is the continue Statement?

The continue statement skips the rest of the current loop iteration and jumps straight to the next one, without exiting the loop entirely.

02Why is it used?

Sometimes you want to skip just one specific case while still continuing the loop for everything else — like skipping negative numbers while still processing the rest of a list.

03Real-Life Example

Think of a teacher calling out roll numbers for a fitness test, but skipping students who are absent that day — the teacher doesn't stop the whole test, they just move on to the next name.

04Syntax

java
for (...) { if (condition) { continue; // skips to next iteration } // remaining code in the loop }

05Example Program

java
public class ContinueDemo { public static void main(String[] args) { for (int i = 1; i <= 5; i++) { if (i == 3) { continue; } System.out.println(i); } } }

Output:

1
2
4
5

06Key Points to Remember

  • continue skips only the current iteration; the loop itself keeps running.
  • It's different from break, which stops the loop entirely.
  • Overusing continue in complex loops can sometimes make code harder to follow — use it thoughtfully.