[Solved] Why does variable i not change after i=i++?


Why does this code print 10 times “Hello world.”?

No, this will be an infinite loop because the following statement resets the value of k to 1:

k=+1;

Also, k=k++ will not change the value of k because it is processed something like

int temp = k;
k++;
k = temp;

You can try the following code to verify this:

int k = 1;
k = k++;
System.out.println(k); // Will print 1

4

solved Why does variable i not change after i=i++?