Back to the main page
Good code should ideally use parentheses to make clear the intended order of multiple operations in an expression. But not every developer is so diligent. Below lists the hierarchy of precedence for java operators.
| method calling | . |
| postfix | var++ var-- |
| unary | ++var --var -var ~var !var |
| cast and object creation | () new |
| multiplicative | * / % |
| additive | + - |
| shift | << >> >>> |
| relational | < > <= >= instanceof |
| equality | == != |
| bitwise AND | & |
| bitwise exclusive OR | ^ |
| bitwise inclusive OR | | |
| logical AND | && |
| logical OR | || |
| ternary | ?: |
| assignment | = += -= *= /= %= &= ^= |= <<= >>= >>>= |