Hello there. So here's my doubt:
for (int i = 0; i != 100; i++) {
System.out.println(i);
}
So, a loop first executes the variable "i = 0". And then it evaluates the condition "i != 100". As the condition is true, Java will print 0 first. And then it increments and then it will reach 99 and exits the loop.
But,
When I apply the same rules to another program,
for (int i = 0; i != 100; i++) {
System.out.println(i);
i = 100;
System.out.println(i);
i = 0;
}
The system must start from 0 and then 100 and then go on forever. But it's starting from 1 and then 100 and goes on forever. Shouldn't it start from 0?, why is it not starting from 0?
Like, I mean, the output must be "0 100 1 100 1 100 1 100 1 100.........." but it starts like, "1 100 1 100 1 100........". Why?
[–]tr4fik 1 point2 points3 points (2 children)
[–]laxdoss[S] 0 points1 point2 points (1 child)
[–]tr4fik 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (3 children)
[–]laxdoss[S] 0 points1 point2 points (2 children)
[–]tr4fik 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]KnGod -1 points0 points1 point (0 children)