Consider the following code :
public class Game {
public static void main(String[] args) {
int x = 0;
while (x < 1) {
x = x++;
}
}
}
With my compiler this code goes into infinite loop , but why ?
First , we place the value of x
into x
, and only then we add 1 to x
, and afterwards I would expect that 1 < 1
would be false , and the while loop would terminate ...
But no , that doesn't happen .
So what might be the reason for the infinite loop ?