In an expression x && y, y will not be evaluated when x is false. However, in x || y, y *is* evaluated if x is false (it would not be evaluated if x was true). As was already pointed out in this
thread, x && y || z is the same as (x && y) || z.
In x && y || z, y is not evaluated if x is false, but z is evaluated, and if z is true, the result is true.
The output is:
false
true-2
hello
true-1 is not printed because, indeed, the expression to the right of && is not evaluated if the one to the left of && is false.
The expression to the right of || is evaluated, and so the result is (false || true), which is true.
(
made private methods static - see next post)
[ September 18, 2006: Message edited by: Barry Gaunt ]