Java Continue Statement
🔷 What is the continue
statement?
In Java, The continue
statement skips the current iteration of a loop and moves to the next iteration.
🔷 Syntax:
🔷 Where can continue
be used?
-
Inside
for
,while
, anddo-while
loops
📘 Example: Skipping an iteration
Output:
🔎 Explanation:
When i == 3
, the continue
statement skips the rest of the loop and jumps to the next value of i
.
🔄 Difference between break
and continue
Feature | break |
continue |
---|---|---|
Purpose | Exits the loop entirely | Skips current iteration only |
Affects | Entire loop | Single iteration |
Used in | Loops and switch | Loops only |