public static void main(String[] args) {
for (int i = 0; i < 5; i++) {
System.out.println(i++);
}
}
}
iteration 1:
--------------
i value is 0; (0<5
test is pass)
prints 0 then increments i value (i is now 1) //output is: 0
i is incremented in for loop (i is now 2)
iteration 2:
------------
i value is 2; (2<5 test is pass)
prints 2 then increments i value (i is now 3)//output is: 0 2
i is incremented in for loop (i is now 4)
iteration 3:
------------
i value is 4; (4<5 test is pass)
prints 4 then increments i value (i is now 5) //output is: 0 2 4
i is incremented in for loop (i is now 6)
iteration 4:
------------
i value is 6; (6<5 test is fail)
So the final output is: 0 2 4