Java Reference
In-Depth Information
Precedence
Level
Operator
Operation
Associates
14
?:
conditional operator
R to L
=
+=
+=
-=
*=
/=
%=
<<=
>>=
>>>=
&=
&=
ˆ=
ˆ=
|=
|=
R to L
15
assignment
addition, then assignment
string concatenation, then assignment
subtraction, then assignment
multiplication, then assignment
division, then assignment
remainder, then assignment
left shift, then assignment
right shift (sign), then assignment
right shift (zero), then assignment
bitwise AND, then assignment
boolean AND, then assignment
bitwise XOR, then assignment
boolean XOR, then assignment
bitwise OR, then assignment
boolean OR, then assignment
FIGURE D.1
Java operator precedence, continued
rules are essentially the same. Figure D.3 shows the results of bitwise operators on
all combinations of two bits. Compare this chart to the truth tables for the logical
operators in Chapter 5 to see the similarities.
The bitwise operators include the XOR operator, which stands for exclusive
OR. The logical || operator is an inclusive OR operation, which means it returns
true if both operands are true. The | bitwise operator is also inclusive and yields a
Operator
Description
~
bitwise NOT
&
bitwise AND
|
bitwise OR
ˆ
bitwise XOR
<<
left shift
>>
right shift with sign
>>>
right shift with zero fill
FIGURE D.2 Java bitwise operators
 
Search WWH ::




Custom Search