【发布时间】:2013-06-13 11:20:21
【问题描述】:
谁能告诉我为什么它打印出 1? 我肯定知道 true 和 false AND EXCLUSIVE 给出 0。为什么它进入 if 语句?
public static void main(String[] args) {
boolean a=true, b=false;
int i=0;
if(a^b) {
i++;
}
System.out.print(i++);
}
谢谢!
【问题讨论】:
-
实际上它是 XOR aka OR EXCLUSIVE,它给出了 true。
标签: java