Java Reference
In-Depth Information
equality
== !=
AND
&
exclusive
OR
^
inclusive
OR
|
conditional
AND
&&
conditional
OR
||
conditional
?:
= += -= *=
/= %= >>=
<<= >>>=
&= ^= |=
assignment
All binary operators except assignment operators are left-associative.
Assignment is right-associative. In other words,
a=b=c
is equivalent to
a=(b=c)
, so it is convenient to chain assignments together. The condi-
tional operator
?:
is right-associative.
Parentheses are often needed in expressions in which assignment is em-
bedded in a boolean expression, or in which bitwise operations are used.
For an example of the former, examine the following code: