What does a bitwise exclusive OR do in Java?

后端 未结 4 912
天涯浪人
天涯浪人 2020-12-20 19:18

Given:

public class Spock {
    public static void main(String[] args) {
        Long tail = 2000L;
        Long distance = 1999L;
        Long story = 1000L         


        
4条回答
  •  忘掉有多难
    2020-12-20 19:46

    You are using boolean exclusive OR and this is much the same as !=. In the first case, both conditions are true and in the second, both conditions are false so neither branch is taken. (You can check this with the debugger in your IDE)

    The only real difference is that != has higher precedence than & which is higher than ^

提交回复
热议问题