For more information on the cast operator, see Casts in Java.
Operator | Meaning | Operand(s) | Precedence | Associativity |
---|---|---|---|---|
[ ] | Array Index | Integer | 16 |   |
( ) | Method Call | Method | 16 |   |
new | Object Allocation | Class | 16 |   |
. | Member | Class or object | 15 | Left-to-right |
- | Unary minus | Numeric | 14 | Right-to-left |
+ | Unary plus | Numeric | 14 | Right-to-left |
~ | Bitwise complement | Numeric | 14 | Right-to-left |
! | Logical negation | Boolean | 14 | Right-to-left |
(datatype) | Cast (mod) | Any | 14 | Right-to-left |
++ | Postincrement | Numeric | 14 | Right-to-left |
-- | Postincrement | Numeric | 14 | Right-to-left |
++ | Preincrement | Numeric | 13 | Right-to-left |
-- | Preincrement | Numeric | 13 | Right-to-left |
* | Multiplication | Numeric | 12 | Left-to-right |
/ | Division | Numeric | 12 | Left-to-right |
% | Remainder (mod) | Numeric | 12 | Left-to-right |
+ | Addition | Numeric | 11 | Left-to-right |
- | Subtraction | Numeric | 11 | Left-to-right |
<< | Left shift | Numeric | 10 | Left-to-right |
>> | Right shift1 | Numeric | 10 | Left-to-right |
>>> | Right shift2 | Numeric | 10 | Left-to-right |
> | Greater than | Numeric | 9 | Left-to-right |
>= | Greater than or = | Numeric | 9 | Left-to-right |
< | Less than | Numeric | 9 | Left-to-right |
<= | Less than or = | Numeric | 9 | Left-to-right |
instanceof | Type comparison | Any | 9 | Left-to-right |
== | Equal to | Any | 8 | Left-to-right |
!= | Not equal to | Any | 8 | Left-to-right |
& | Bitwise And | Numeric | 7 | Left-to-right |
& | Logical And3 | Boolean | 7 | Left-to-right |
^ | Bitwise XOr4 | Numeric | 6 | Left-to-right |
^ | Logical XOr5 | Boolean | 6 | Left-to-right |
| | Bitwise Or | Numeric | 5 | Left-to-right |
| | Logical Or5 | Boolean | 5 | Left-to-right |
&& | Logical And6 | Boolean | 4 | Left-to-right |
|| | Logical Or7 | Boolean | 3 | Left-to-right |
?   : | Conditional8 | Boolean, Any | 2 | Right-to-left |
See 9 | Assignment operators | Numeric | 1 | Right-to-left |
1Right shift with sign extension.
2Right shift with zero extension.
3Logical And without short circuit evaluation. Both operands are evaluated.
4XOr means exclusive or.
5Logical Or without short circuit evaluation. Both operands are evaluated.
6Logical And with short circuit evaluation. If first operand is false, the second operand is not evaluated.
7Logical Or with short circuit evaluation. If first operand is true, the second operand is not evaluated.
8Tertiary conditional operator. In expr ? val1 : val2, if expr is true, val1 is returned, otherwise val2 is returned.
9The most commonly used assignment operator is =. In x = expr, the value of expr is assigned to the variable x. In x += expr, the value of expr is added to x and the result becomes the new value of x (expr updates the value of x via the operation +). The other assignment operators -=, *=, /=, %=, >>=, <<=, <<<=, &=, ^=, |= analogously update the value of x via the given operation.