Java - Operator Operator Precedence

Introduction

The following table lists Java operators in their precedence order.

Operators in the same level have the same precedence.

A lower the value in the level column indicates a higher precedence.

Level
Operator Symbol
Action Performed
1





++
--
+, -
~
!
(type)
Pre-or-post increment
Pre-or-post decrement
Unary plus, unary minus
Bitwise complement
Logical Not
Cast
2
*, /, %
Multiplication, division, modulus
3

+, -
+
Addition, subtraction
String concatenation
4


<<
>>
>>>
Left shift
Signed right shift
Unsigned right shift
5




<
<=
>
>=
instanceof
Less than
Less than or equal
Greater than
Greater than or equal
Type comparison
6

==
!=
Equal in value
Not equal to
7

&
&
Bitwise AND
Logical AND
8

^
^
Bitwise XOR
Logical XOR
9

|
|
Bitwise OR
Logical OR
10
&&
Logical short-circuit AND
11
||
Logical short-circuit OR
12
?:
Ternary
13

=
+=, -=, *=, /=, %=, <<=, >>=, >>>=, &=, |=,^=
Assignment
Compound assignment