public class num {
public static void main(String args[]) {
int i = 5, j = 9, k = 3;
int w, x;
w = i | j | k;
x = i &j & k;
System.out.println(w);
System.out.println(x);
}
}
为什么值为w = 15
和x = 1
?
答案 0 :(得分:7)
&
和|
为bitwise operators(分别为AND和OR)。
5 -> 101
3 -> 11
9 -> 1001
----
AND 0001 = 1
OR 1111 = 15