Precedence |
| BASIC |
Precedence rules tell in what order operations are done. For example,
the rules tell you that 2+3*4 is 14, not 20.
In an arithmetic expression,
10 - 5 - 1
is 4, not 6).In a condition,
!) is done before "and" (&&)&&) is done before "or"
(||).For example,
means .
| STYLE |
Because there are a lot of operations in Java, most programmers do not know the complete table of precedence. Therefore, you should use parentheses for any expressions not fully covered by the above rules.
| ADVANCED |
Every operator has a precedence, as given by Sun's precedence table.