Classes/Objects  «Prev


Operator Precedence Association

Java Operator Precedence

Level Operator Description Association
1 []
()
.
Array index
Invoke a method
Member access(instance field /method)
Left to right
2 ++, --
++, --
Postfix-increment, postfix-decrement
Prefix-increment, prefix-decrement
Right to left
3 !
~
Boolean (logical) NOT
Bitwise NOT
Right to left
4 (type)
new
Type Cast
Object creation
Right to left
5
*, /, % 
Multiplication, Division, Modulus Left to right
6 +, -
+
Addition, subtraction
String concatenation
Left to right
7
<, <=, >, >=
Less than, less than or equal to,
greater than, greater than or equal to
Left to right
instanceof Reference Test Left to right
8 ==, !=
==, !=
Value equality and inequality (Reference)
equality and inequality
Left to right
9 & Bitwise AND/ Boolean AND Left to right
10 ^ Bitwise XOR/ (Exclusive OR) Left to right
11 | Bitwise OR (Inclusive OR) Left to right
12 && Logical AND (conditional AND) Left to right
13 || Logical OR (conditional OR) Left to right
14 ?: Conditional (Ternary) Right to left
15
 =, *=, /=, +=,
 -=, %=, <<=,
 >>=, >>>=, &=
 ^=,   |=   

Assignment and compound assignments Right to left