Newer Version Available
Understanding Operator Precedence
Apex uses the following operator precedence rules:
| Precedence | Operators | Description |
|---|---|---|
| 1 | {} () ++ -- | Grouping and prefix increments and decrements |
| 2 | ! -x +x (type) new | Unary negation, type cast and object creation |
| 3 | * / | Multiplication and division |
| 4 | + - | Addition and subtraction |
| 5 | < <= > >= instanceof | Greater-than and less-than comparisons, reference tests |
| 6 | == != | Comparisons: equal and not-equal |
| 7 | && | Logical AND |
| 8 | || | Logical OR |
| 9 | = += -= *= /= &= | Assignment operators |