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=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