Programming and Problem Solving with Java

(やまだぃちぅ) #1
683

Appendix B


Operator Precedence


In the following table, the operators are grouped by precedence level (hightest to lowest), and
a horizontal line separates each precedence level from the next.


Precedence (highest to lowest)


Operator Assoc.* Operand Type(s) Operation Performed


. LR object, member object member access
[] LR array, int array element access
(args ) LR method, arglist method invocation
++,-- LR variable post-increment, decrement


++,-- RL variable pre-increment, decrement
+,- RL number unary plus, unary minus
~ RL integer bitwise complement
! RL boolean boolean NOT


new RL class, arglist object creation
(type ) RL type, any cast (type conversion)


*, /, % LR number, number multiplication, division, remainder


+, - LR number, number addition, subtraction



  • LR string, any string concatenation


<< LR integer, integer left shift




LR integer, integer right shift with sign extension



LR integer, integer right shift with zero extension





<, <= LR number, number less than, less than or equal



, >= LR number, number greater than, greater than or equal
instanceof LR reference, type type comparison



== LR primitive, primitive equal (have identical values)
!= LR primitive, primitive not equal (have different values)
== LR reference, reference equal (refer to the same object)
!= LR reference, reference not equal (refer to different objects)


& LR integer, integer bitwise AND
& LR boolean, boolean boolean AND


^ LR integer, integer bitwise XOR
^ LR boolean, boolean boolean XOR

Free download pdf