Java XOR Operator Questions

I have some questions about the XOR ^ operator in Java.

I always thought that Java does not have a logical XOR operator, because several people told me that ^ was beaten. Today I found some (unconfirmed) messages (without sources) in which ^ is overloaded in Java, working as a logical XOR for Boolean languages ​​and as a bitwise XOR, for example. for integers.

Which statement is true? Can someone provide some reliable sources?

If ^ is overloaded, what types does it accept?

+4
source share
2 answers

Java

&, ^ | , (§5.1.8) , (§5.6.2).

- .

  • ^ - .

&, ^ | boolean boolean, boolean. (. 5.1.8) .

  • ^ true, ; false.

Java .

+7

^ XOR.

booleans false = 0 true = 1.

, , !

0

All Articles