What does the ^ (caret) mean in Java syntax? Why does 6^3 return 5?
It's the bitwise XOR operator. XOR is exclusive or.
6 in binary (lets assume 4 bits) is 0110, 3 in binary is 0011.
So, we get:
0110
0011 XOR
----
0101
And 0101 is 5.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With