Can anyone explain the use of ^ operator in java with some examples?
Can anyone explain the use of ^ operator in java with some examples?
This is the same as ^ in most languages, just an XOR.
false ^ false == false
true ^ false == true
false ^ true == true
true ^ true == false
That's the bitwise exclusive OR operation. Check out the Bitwise and Bit Shift Operators section of the Java tutorials for more information.
In java ^ operator used for bitwise XOR operation.
Follow this link to see the operator precedence also.