&& has higher precedence, but that does not mean it is evaluated first, it just means that you can imagine parenthesis around the && expression. The left/right short circuit rules have precedence over operator precedence! For example: boolean a = true, b = false, c = true; if( a || (b = true) && c ) System.out.println(b) will print false, because a is true means the right hand side of || is not evaluated. The higher precedence of && just means that you can think of the if statement as being written: if( a || ((b = true) && c) ) System.out.println(b) which makes it clear that the whole && operator and both of its operands constitute the right hand side of the short-circuit or.
Joined: Aug 05, 2001
Thanks for the explaination! In the case of: a || b && c Actually, no matter && or || is evaluated first, the result is the same. [ April 14, 2003: Message edited by: Don Liu ]