Skip to content

Commit ca1b3d8

Browse files
committed
feat: Demonstrate custom initialization and increment in for loop with skip pattern
🧠 Logic: - The loop uses `System.out.println("Hi")` as the initialization block, which runs once before the loop starts. - Loop variable `i` starts at 0, continues while `i <= 10`. - Inside the loop, `i` is printed and then incremented again (in addition to the `i++` in the for-loop). - This causes `i` to increment by 2 on each iteration, printing even-numbered values (0, 2, 4, ...). Signed-off-by: Somesh diwan <[email protected]>
1 parent a7fc0d5 commit ca1b3d8

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

Section8LoopAB/src/ForLoopAB1.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
public class ForLoopAB1 {
22
public static void main(String[] args) {
33
int i =0;
4-
for(System.out.println("Hi"); i<=10;i++)
5-
{
4+
for(System.out.println("Hi"); i<=10;i++) {
65
System.out.println(i);
76
i++;
87
}
98
}
109
}
11-
12-
13-
//initilization and updataion is optional.
14-
15-
//data type must be same.

0 commit comments

Comments
 (0)