What's the difference between XOR and NOT-EQUAL-TO?

前端 未结 6 2086
北恋
北恋 2020-12-15 17:11

My question uses Java as an example, but I guess it applies to probably all.

Is there any practical difference between the XOR operator (^ in Java) and

6条回答
  •  无人及你
    2020-12-15 17:37

    Yes, you can use XOR to test booleans for (in)equality, although the code is less intuitive: if (x ^ y) versus if (x != y).

提交回复
热议问题