Hi Anil,
Look at the JLS section 15.23:
The <code>&&</code> operator is like <code>&</code> (�15.22.2), but
evaluates its right-hand operand only if the value of its left-hand operand is <code>true</code>. It is syntactically left-associative (it groups left-to-right). It is fully associative with respect to both side effects and result value; that is, for any expressions
a,
b, and
c, evaluation of the expression <code>((</code>
a<code>)&&(</code>
b<code>))&&(</code>
c<code>)</code> produces the same result, with the same side effects occurring in the same order, as evaluation of the expression <code>(</code>
a<code>)&&((</code>
b<code>)&&(</code>
c<code>))</code>.
<pre>
<em>ConditionalAndExpression:
InclusiveOrExpression
ConditionalAndExpression && InclusiveOrExpression
</em></pre>
Each operand of <code>&&</code> must be of type <code>boolean</code>, or a compile-time error occurs. The type of a conditional-and expression is always <code>boolean</code>.
At run time, the left-hand operand expression is evaluated first; if its value is <code>false</code>, the value of the conditional-and expression is <code>false</code> and the right-hand operand expression is not evaluated. If the value of the left-hand operand is <code>true</code>, then the right-hand expression is evaluated and its value becomes the value of the conditional-and expression. Thus, <code>&&</code> computes the same result as <code>&</code> on <code>boolean</code> operands. It differs only in that the right-hand operand expression is evaluated conditionally rather than always.
So the lines both evaluate to false, but for line 1 all operands are evaluated and for line 2 only b1, because since b1 is false, the complete expression will be false.
Hope this helps!
[This message has been edited by Peter Voorwinden (edited August 24, 2000).]