Page 783 - Introduction to Programming with Java: A Problem Solving Approach
P. 783

                  APPENDIX 2
   Operator Precedence
The operator groups at the top of the table have higher precedence than the operator groups at the bottom of the table. All operators within a particular precedence group have equal precedence. If an expression has two or more same-precedence operators, then within that expression, those operators execute from left to right or right to left as indicated in the group heading.
 1. grouping and access (left to right):
(<expression>)
(<list>)
[<expression>] <type-or-member>.<type-or-member>
expressions
arguments or parameters indices
member access
2. unary operations (right to left):
x++
x--
post increment post decrement pre increment pre decrement plus
minus
logical inversion bit inversion
object instantiation cast
multiplication division remainder
++x
--x
+x
-x
!x
~
<classname> (<type>) x
new
3. multiplication and division (left to right):
x* y
x/ y
x% y
4. addition and subtraction; concatenation (left to right):
x+ y
x- y
s1 + s2
5. bit shift operations (left to right):
x << n
x >> n
x >>> n
addition
subtraction
string concatenation
arithmetic shift left (*2n)
arithmetic shift right (*2-n; same MS bit) logical shift right (MS bit 􏰀 0)
Figure A2.1a Operator precedence—part A
Apago PDF Enhancer
749





















































   781   782   783   784   785