Skip to content

Commit a582493

Browse files
committed
feat: Demonstrate use of 'continue' statement to skip iteration in loop
🧠 Logic: - A `while` loop prints numbers from 1 to 10. - When `i == 5`, the loop increments `i` and uses `continue` to skip printing 5. - All other numbers are printed normally. - Demonstrates how `continue` skips the rest of the loop body for a specific condition. Signed-off-by: Somesh diwan <[email protected]>
1 parent 68efeb2 commit a582493

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
public class Continue {
22
public static void main(String[] args) {
33
int i=1;
4-
while(i<=10)
5-
{
6-
if(i==5)
7-
{
4+
5+
while(i<=10) {
6+
if(i==5) {
87
i++;
98
continue;
109
}
1110
System.out.println(i);
1211
i++;
1312
}
1413
}
15-
}
14+
}

0 commit comments

Comments
 (0)