What is Java Operator Precedence?
Java operator precedence is how Java determines which operator to evaluate first.
In this chart, operator precedence is displayed from highest precedence to lowest precedence.
| Priority | Operator | Operation | Order of Evaluation |
|---|---|---|---|
| 1 | [ ] |
Array index | Left to Right |
() |
Method call | ||
. |
Member access | ||
| 2 | ++ |
Prefix or postfix increment | Right to Left |
-- |
Prefix or postfix decrement | ||
+ - |
Unary plus, minus | ||
~ |
Bitwise NOT | ||
! |
Boolean (logical) NOT | ||
(type) |
Type cast | ||
new |
Object creation | ||
| 3 | * / % |
Multiplication, division, remainder | Left to Right |
| 4 | + - |
Addition, subtraction | Left to Right |
+ |
String concatenation | ||
| 5 | << |
Signed bit shift left to right | Left to Right |
>> |
Signed bit shift right to left | ||
>>> |
Unsigned bit shift right to left | ||
| 6 | < <= |
Less than, less than or equal to | Left to Right |
> >= |
Greater than, greater than or equal to | ||
instanceof |
Reference test | ||
| 7 | == |
Equal to | Left to Right |
!= |
Not equal to | ||
| 8 | & |
Bitwise AND | Left to Right |
& |
Boolean (logical) AND | ||
| 9 | ^ |
Bitwise XOR | Left to Right |
^ |
Boolean (logical) XOR | ||
| 10 | | |
Bitwise OR | Left to Right |
| |
Boolean (logical) OR | ||
| 11 | && |
Boolean (logical) AND | Left to Right |
| 12 | || |
Boolean (logical) OR | Left to Right |
| 13 | ? : |
Conditional | Right to Left |
| 14 | = |
Assignment | Right to Left |
*= /= += -= %= |
Combinated assignment (operation and assignment) |
Notes:
- Expressions inside parentheses are evaluated first
- Nested parentheses are evaluated from the innermost parentheses to the outermost parenthesis.
- Operators in the same row in the chart have equal precedence.
|
Bookmark What is Java Operator Precedence?


