In the following table, the operators are grouped by precedence level (highest to lowest), and a horizontal line separates each precedence level from the next-lower level.
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 |
| |
LR | integer, integer | bitwise OR |
| |
LR | boolean, boolean | boolean OR |
&& |
LR | boolean, boolean | conditional AND (short circuit evaluation) |
|| |
LR | boolean, boolean | conditional OR (short circuit evaluation) |
?: |
RL | boolean, any, any | conditional (ternary) operator |
= |
RL | variable, any | assignment |
*=, /=, %=, +=, -=, |
|||
>>=, >>>=, &=, ^=, |= |
RL | variable, any | assignment with operation |
*LR means left-to-right associativity; RL means right-to-left associativity. |
18.226.104.153