public class Temp {
public static void main(String[] args) {
for (int i = 0; i < 10;){
i = i++;
System.out.println("Hello world");
}
}
}
why i
does not get increment as we are incrementing it still it does not get increment
as we can see in the for loop when we are doing post-increment it isnt working and it goes to infinite loop, when we are doing pre-increment
i = ++i
its working properly and even when we are doing like i = (i=i+1)
here also it working
but not when we are doing post increment
i is assign to i++ and that time value of i was 0 but immediately after it got increment by 1 than it should reflect on next loop iteration
why it is not reflecting?