Originally Posted by
lightOfDay
& is not a logical operator, strictly.
Well, actually, and strictly, it
is when both operands are boolean. This according to the Java Language Specification. (Paragraph 15.22.2 in version 3 of the jls.) Same for '^' and '|'
15.22.2 Boolean Logical Operators &, ^, and |
When both operands of a &, ^, or | operator are of type boolean or Boolean, then
the type of the bitwise operator expression is boolean. In all cases, the operands
are subject to unboxing conversion (§5.1.8) as necessary.
For &, the result value is true if both operand values are true; otherwise, the
result is false.
For ^, the result value is true if the operand values are different; otherwise,
the result is false.
For |, the result value is false if both operand values are false; otherwise,
the result is true.
So, it is not just some squirrelly little thing that "Just Happened." The behavior has been deterministically specified by the author and maintainers of the language.
Cheers!
Z