Originally posted by Ankur Bhatt:
Marc I didn't get your post. LHS of || is true, then why it checked RHS side. Secondly, for your 2nd comment - there is no point to see left association as || has higher precedence.
Well, the operator || evaluates its right-hand operand
only if the value of its left-hand operand is false. In this case, the LHS is true, so it does
not evaluate the RHS (which is demonstrated in the output by b and c remaining false).
Evaluation from left to right only implies a "left-associative operation," and does not imply that || has higher precedence. Indeed, && apparently does have precedence over ||...
See
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/expressions.html But I have to admit that I'm at a loss in understanding why && and || do not share the same precedence (like multiplication, division, and modulo). Given their short-circuiting behavior, how would we
demonstrate that && does, in fact, have precedence over ||?

[ September 07, 2004: Message edited by: marc weber ]