Consider the following example:
class Quirky {
public static void main(String[] args) {
int x = 1;
int y = 3;
System.out.println(x =
It is not the same. The left hand side will always be evaluated before the right hand side, and the brackets don't specify an order of execution, but a grouping of commands.
With:
x == (x = y)
You are basically doing the same as:
x == y
And x will have the value of y after the comparison.
While with:
(x = y) == x
You are basically doing the same as:
x == x
After x took y's value. And it will always return true.