Let's consider
int x=1;
int y1 = (x=10) + x;
System.out.println(y1);
// prints 20
x = 1;
int y2 = x + (x=10);
System.out.println(y2);
// prints 11
In the first example, () is executed first as it has the highest precedence; sets x
value to 10 and hence the right-hand operand (x) gets the new value 10 and so y1 = 10+10 = 20
In the second example, the left-hand operand 'x' gets its value 1, then () is executed and x gets its new value 10, so y2 = 1+10 = 11;
Why in the 2nd example, () doesn't get executed first; so (x=10) gets executed first and the left-hand operand x should be set to its new value 10 and hence y2 = 20; but it didn't happen this way?