← Back to Chapters

Java continue Statement

? Java continue Statement

? Quick Overview

The continue statement in Java is used to skip the current iteration of a loop and move directly to the next iteration.

? Key Concepts

  • Used only inside loops
  • Skips remaining statements in the current iteration
  • Execution jumps to loop condition
  • Works with for, while, and do-while loops

? Syntax / Theory

? View Code Example
// Basic syntax of continue statement
continue;

? Code Example

? View Code Example
// Skip number 5 using continue
public class ContinueDemo {
public static void main(String[] args) {
for(int i = 1; i <= 10; i++) {
if(i == 5) {
continue;
}
System.out.println(i);
}
}
}

? Live Output / Explanation

Output

1 2 3 4 6 7 8 9 10

When the loop variable becomes 5, the continue statement skips printing and moves to the next iteration.

✅ Tips & Best Practices

  • Use continue for skipping specific conditions
  • Avoid excessive use to maintain readability
  • Prefer clear conditional checks

? Try It Yourself

  • Skip all even numbers in a loop
  • Use continue inside a while loop
  • Apply continue with user input conditions