jls
15.7 Evaluation Order
The
Java programming language guarantees that the operands of operators appear to be evaluated in a specific evaluation order, namely, from left to right.
....
15.7.3 Evaluation Respects Parentheses and Precedence
Java programming language implementations must respect the order of evaluation as indicated explicitly by parentheses and implicitly by operator precedence.
My question is that these seem a bit contradictory to me. If evaluation order is always from left to right, then how can it be affected by parentheses or operator precedence? I can understand that the actual grouping of expression depend on operator associativity, and may be changed by using parentheses.
for eg a*b*c is same as (a*b)*c and not a*(b*c). But this is different from order of evaluation. For eg.
x = f1()+f2()*f3(); results in f1() invoked before f2() and
f3(), which supports 15.7 above, that the order is always from left to right.
Any views?