0 java bit-manipulation operator-keyword
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);
}
}
Run Code Online (Sandbox Code Playgroud)
为什么价值观w = 15和x = 1?
&并且|是按位运算符(分别是AND和OR).
5 -> 101
3 -> 11
9 -> 1001
----
AND 0001 = 1
OR 1111 = 15
Run Code Online (Sandbox Code Playgroud)