You are thinking of a single-bit, exclusive-or operation:
0 EXOR 0 is 0
0 EXOR 1 is 1
1 EXOR 0 is 1
1 EXOR 1 is 0
But the
Java ^ operation on integral types is a
bitwise operation.
The operation defined above is applied to all the bits of the ^ operands,
in parallel, as the previous poster demonstrated.
Also note than ^ is defined for booleans, and does want you wish: the
result is true iff the operand have different boolean values:
false ^ false is false
false ^ true is true
true ^ false is true
true ^ true is false
But then again, you get the same result with boolean's == operation.