The logical XOR operator exists in Java and is written ^ .
To get the terminology correct, in Java:
& , | and ^ are called bitwise or logical operators, depending on the types of their arguments;&& and || are called conditional statements.
See JLS Β§ 15.22 for details. Bitwise and logical operators .
There is no direct equivalent for && and || for xor . The only reason && and || exists as separate operators from & , and | - their short circuit behavior (which is why they are called "conditional"), and XOR cannot be shorted.
source share