y < 2 = false
doStuff() = true
so you probably already know
true AND true = true
true AND false = false
true OR true = true
true OR false = true
so basically your if statement breaks down to
as long as you have an OR that evaluates to true it will be evaluated as true
however something likewould evaluate to false. always work from inside parenthesis to outside. simplified this could be represented as and simplified still further would be
Hope that helps at all.
Naveen Megharaj wrote:i know that it will print true, but i want to know how the "condition" with in the "if statement" simplifies.........
A couple of points.... First, the logical AND has higher precedence than the logical OR, so the condition would be like this (if using parens)....
Second, the logical AND is a short circuit operator, so when the "x>3" portion is false, it will skip the check for the "y<2", and immediately return false.
Third, the logical OR is also a short circuit operator, but can't short circuit because the left side is false. It will call the doStuff() method which returns true -- and generates a logical OR result of true.
Hence, the condition in the "if" statement is true...
Henry Wong wrote:
Fred Hamilton wrote:I don't see the actual doStuff() method here, but it must be a Boolean method right? How can we say it returns true if we don't know the method?
This was stated in the original post -- that the doStuff() method returns true.
ahh right you are. I had not picked up on that.