public class Spock { public static void main(String[] args) { Long tail = 2000L; Long distance = 1999L; Long story = 1000L; if ((tail > distance) ^ ((story * 2) == tail)) System.out.print("1"); if ((distance + 1 != tail) ^ ((story * 2) == distance)) System.out.print("2"); } }
What is the result?
A. 1
B. 2
C. 12
D. Compilation fails.
E. No output is produced.
F. An exception is thrown at runtime.
答案:E
解析:
運算符號(^) 表示 XOR
true^true→false
false^false→false
true^false→true
0 意見:
張貼留言