Java Reference
In-Depth Information
logical inclusive OR
|
logical exclusive or ( XOR )
^
logical negation
!
conditional AND
&&
conditional OR
||
A "logical AND " is true if and only if both its operands are true, while a
"logical OR " is true if and only if either of its operands are true. The "ex-
clusive OR " operator yields true if either, but not both, of its operands is
truewhich is the same as testing the equality of the two operands, so we
can rewrite our earlier example as:
if ((x < 0) ^ (y < 0))
differentSign();
else
sameSign();
The unary operator ! negates, or inverts, a boolean, so !true is the same
as false and !false is the same as true .
Boolean values are normally tested directlyif x and y are booleans, the
code
 
Search WWH ::




Custom Search