I not only use all the brains that I have, but all that I can borrow. [Laurence J. Peter]
Q4: m1()
1: true
===
Q4: m1()
Q4: m3()
1: true
Done
Press any key to continue...
Hey! It compiles! Ship it!
Hey! It compiles! Ship it!
I would say that a || operator short-circuits the whole of the remaining expression, providing no parentheses comes into the sceene. The point is that the && operator does not behave exactly equal. A false value to the left of && will short-circuit only sucessive && operators to its right, untill the first || operator on its right.
SCJP2. Please Indent your code using UBB Code
Now the second statement is:
b1 = m1(0) && m2(1) || m3(1);
1. m1(0) is called, it is false
2. So why is the && operator not getting short circuited directly at this point?
It skips the m2(1) and goes ahead to proceed m3(1)...Why is it going ahead to preceed with the rest of the statement?
If the rule is that the whole statement has to be processed, then why did the first statement not do that?
I am really confused....please help...I am taking the exam in 2 days....