posted 22 years ago
Padmini
the first quote you give says that evaluation of the arguments is not determined by precedence or parenthesis.
Basically what it is saying is that in an expression all of the arguemnts are evaluated before any or the operations are performed. They are evaluated left to right.
Look at this, fragment:
int a=1, c=25, d=2, e=5, f=6;
int b = c * (a + c=2) / (d + e) - (f + c)
the values of a, c, d, e and f will all be determined before any of the operations are performed. Note the assignment in the middle: c=2. Because the operands are evaluated left to right the final expression looks like this:
int b = 25 * (1 + 2) / (2 + 5) - (6 + 2)
the first place c is used it has its original value of 25, then it is assigned the value of 2 and that is the value of it throughout the rest of the expression. Even though the parenthesis would lead you to think that the (a + c=2) wold be the first thing done.
The sentence that you quoted in the JLS is refering to the evaluation of the value of the expression as a whole, not the value of the operands.
hope that helps
Dave
[This message has been edited by Dave Vick (edited June 18, 2001).]