The operators in Java, shown in order of precedence - from highest to lowest

Operator | Description | Level | Associativity |
---|---|---|---|

[] . () ++ -- |
access array element access object member invoke a method post-increment post-decrement |
1 | left to right |

++ -- + - ! ~ |
pre-increment pre-decrement unary plus unary minus logical NOT bitwise NOT |
2 | right to left |

() new |
cast object creation |
3 | right to left |

* / % |
multiplicative | 4 | left to right |

+ - + |
additive string concatenation |
5 | left to right |

<< >> >>> |
shift | 6 | left to right |

< <= > >= |
relational type comparison |
7 | left to right |

== != |
equality | 8 | left to right |

& | bitwise AND | 9 | left to right |

^ | bitwise XOR | 10 | left to right |

| | bitwise OR | 11 | left to right |

&& | conditional AND | 12 | left to right |

|| | conditional OR | 13 | left to right |

?: | conditional | 14 | right to left |

= += -= |
assignment | 15 | right to left |

Priority | Operators | Operation | Associativity |
---|---|---|---|

1 | [ ] | array index | left |

() | method call | ||

. | member access | ||

2 | ++ | pre- or postfix increment | right |

-- | pre- or postfix decrement | ||

+ - | unary plus, minus | ||

~ | bitwise NOT | ||

! | boolean (logical) NOT | ||

(type) | type cast | ||

new | object creation | ||

3 | * / % | multiplication, division, remainder | left |

4 | + - | addition, substraction | left |

+ | string concatenation | ||

5 | << | signed bit shift left | left |

>> | signed bit shift right | ||

>>> | unsigned bit shift right | ||

6 | < <= | less than, less than or equal to | left |

> >= | greater than, greater than or equal to | ||

instanceof | reference test | ||

7 | == | equal to | left |

!= | not equal to | ||

8 | & | bitwise AND | left |

& | boolean (logical) AND | ||

9 | ^ | bitwise XOR | left |

^ | boolean (logical) XOR | ||

10 | | | bitwise OR | left |

| | boolean (logical) OR | ||

11 | && | boolean (logical) AND | left |

12 | || | boolean (logical) OR | left |

13 | ? : | conditional | right |

14 | = | assignment | right |

Updated: Friday, September 11, 2015 5:14 AM