In method or class scope, the line below compiles (with warning):
int x = x = 1;
In class scope, where variables get their default valu
In java or in any modern language, assignment comes from the right.
Suppose if you are having two variables x and y,
int z = x = y = 5;
This statement is valid and this is how the compiler splits them.
y = 5;
x = y;
z = x; // which will be 5
But in your case
int x = x + 1;
The compiler gave an exception because, it splits like this.
x = 1; // oops, it isn't declared because assignment comes from the right.