Java : Operators Precedence in Expression


In an expression statement, precedence decides the order of operations performed based on operator use. Following is the list all operators in Java and it’s having precedence and execution direct of operators.

“Operators with higher precedence are executed before those of lower precedence.”

Precedence Operator Description Association
1 ++,– Postincrement, Postdecrement R -> L
2 ++,–+,- ~ ! Pre-increment, Predecrement Unary plus, unary minus Bitwise complement Boolean NOT R -> L
3 new
(Type)
Create Object
Typecast
R -> L
4 *,/,% Multiplication, division, remainder L -> R
5 +-
+
Addition, subtraction
String Concatenation
L -> R
6 <>, >>> Left shift, right shift, unsigned right shift L -> R
7 <, , >=instanceof Type Comparison L -> R
8 ==, !=
==, !=
Value equality and inequality
Reference equality and inequality
L -> R
9 &
&
Boolean AND
Bitwise AND
L -> R
10 ^
^
Boolean XOR
Bitwise XOR
L -> R
11 |
|
Boolean OR
Bitwise OR
L -> R
12 && Conditional AND L -> R
13 || Conditional OR L -> R
14 ?: Conditional Ternary Operator L -> R
15 =,+=,-=,*=,/ =,%=,&=,^=, |=,<> =,>>>= Assignment Operators R -> L

See Also :

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s