12 < 6 && 18 > 1 evaluates to
|AND Operator &&|
You may have noticed something in answering the question: you can get the correct answer to the question by evaluating just the first part of the expression:
12 < 6 && 18 > 1 ------ false
&& anything is
there is no need
to continue after the
false has been evaluated.
this is how Java operates:
X && Y, first evaluate X. If X is
falsethen stop: the whole expression is
false. Otherwise, evaluate Y then AND the two values.
This idea is called short-circuit evaluation.
Programmers frequently make use of this feature.
say that two methods that return
are combined in a boolean expression:
if ( methodThatTakesHoursToRun() && methodThatWorksInstantly() ) ....
Suggest a better (but logically identical) way to arrange this boolean expression.