有人可以解释为什么以下程序打印输出为7
公共课测试{
public static void main(String []args){
int i =1;
int j =2;
int k= 5;
System.out.println(i|j|k);
}
Run Code Online (Sandbox Code Playgroud)
}
我想知道OR操作是如何在java int中发生的.
rge*_*man 11
1 = 00000001
2 = 00000010
5 = 00000101
============
7 = 00000111 // 1 where the corresponding bit is set in any of the above numbers
Run Code Online (Sandbox Code Playgroud)