In order to solve complicated expressions, we need Operator Precedence and Associativity of Operators.
Precedence: means the priority of operators
Associativity: indicates in what order operators of equal precedence in an expression are applied
Order |
Category |
Operator |
Operation |
Associativity |
1
|
|
( ) ,[ ]
|
|
L → R |
2 |
Unary
|
!
|
Logical negation (NOT) |
R → L
|
4
|
Multiplication
|
*
|
Multiply
|
L → R
|
5
|
Additive
|
+
|
Binary Plus
|
L → R
|
6
|
Shift
|
<<
|
Shift Left
|
L → R
|
7
|
Relational
|
<
|
Less than
|
L → R
|
8
|
Equality
|
==
|
Equal to
|
L → R
|
9
|
Bitwise AAND
|
&
|
Bitwise AND
|
L → R
|
10
|
Bitwise XOR
|
^
|
Bitwise XOR
|
L → R
|
11
|
Bitwise OR
|
|
|
Bitwise OR
|
L → R
|
12
|
Logical AND
|
&&
|
Logical AND
|
L → R
|
14
|
Conditional
|
? :
|
Ternary Operator
|
R → L
|
15
|
Assignment
|
= ,*=
|
|
R → L
|