When more than one operator is used in an expression, Java has an established precedence hierarchy to determine the order in which operators are evaluated. In many cases, this precedence determines the overall value of the expression.
In general, the order of evaluation from first to last is the following:
- Increment and decrement operations
- Arithmetic operations
- Comparisons
- Logical operations
- Assignment expressions
If two operations have the same precedence, the one on the left in the actual expression is handled before the one on the right. This following table shows the specific precedence of the various operators in Java. Operators farther up the table are evaluated first.
