Is there an exclusive OR (XOR) in Java? Where it's one or the other but not both? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is there an exclusive OR (XOR) in Java? Where it's one or the other but not both?

22nd Nov 2015, 7:53 PM
Trevor Holmbeck
Trevor Holmbeck - avatar
3 Answers
+ 3
No, but you can easily create one: public static boolean logicalXOR(boolean x, boolean y) { return ( ( x || y ) && ! ( x && y ) ); }
17th May 2016, 1:51 PM
James Flanders
0
I don't think so
26th Dec 2015, 6:11 PM
Hussain AlMarkhi
Hussain AlMarkhi - avatar
0
x XOR y in java: x^y
11th Jul 2016, 12:02 PM
lucasltv
lucasltv - avatar