“|=”是啥意思?该怎么处理

   阅读
“|=”是啥意思?
比如notification.flags |= Notification.FLAG_AUTO_CANCEL
“|=”是啥意思?

------解决方案--------------------
是"!="吧,肯定是打错了!
------解决方案--------------------
Java code

 public static void main(String []args){

      boolean False =false;
      False |= true;
      False = False | true; // & ^ | 与 或 非
      System.out.println(False);
  }

------解决方案--------------------
疼的程序... 
注意提示
// & ^ | 与 或 非

应该是 False|true的结果给False
|=
应该和+= 工作方法一样.
------解决方案--------------------
在C++ 语言好像经常看到这种写法,我没记错的话,应该是
notification.flags |= Notification.FLAG_AUTO_CANCEL
notification.flags 和后面的 Notification.FLAG_AUTO_CANCEL做异或 
把notification.flags除去Notification.FLAG_AUTO_CANCEL这种属性



------解决方案--------------------
这个太不常用了吧~~让人看不懂啊。
------解决方案--------------------
|=一般用于二进制
举个例子吧
Java code

int a = 1,b = 2,c = 4;//0x0001,0x0010,0x0100
a |= b;// a = 0x0011 = 3
b |= c;// b = 0x0110 = 6

------解决方案--------------------
notification.flags = notification.flags|Notification.FLAG_AUTO_CANCEL
------解决方案--------------------
notification.flags = notification.flags | Notification.FLAG_AUTO_CANCEL
------解决方案--------------------
这个是用于二进制。
------解决方案--------------------
位运算,按位或 等于,

notification.flags = notification.flags | Notification.FLAG_AUTO_CANCEL

比如
int a = 5;
int b = 3;
System.out.println(a|=b);
输出7,
5 的二进制 是 0 11,
3 的二进制 是 0 101
按位或 运算
有一个为1 就是1 
结果 : 0 111 (2的二次方+加2的一次方+1) 7
------解决方案--------------------
这个称为“布尔或赋值运算符”或者“位与赋值运算符”
------解决方案--------------------
notification.flags |= Notification.FLAG_AUTO_CANCEL

相当于

notification.flags = notification.flags | Notification.FLAG_AUTO_CANCEL

跟常见的 += 一样的。

int i = 0;
i += 2;
------解决方案--------------------
尝试理解下下面这个示例

1 代表 女的
2 代表 男的

4 代表 教授
8 代表 禽兽

那么一个实体 男禽兽 就是 flag = 2 | 8; flag 等于 10
如果既是教授又是禽兽,那么 flag = 4 | 8,还是个男的 flag |= 2;

这个方式在很多需要一个值标识多种状态下普遍适应
------解决方案--------------------
c语言里边用的很多,android程序中用的也很多,很多搞嵌入式的程序员写java程序就喜欢用位运算
------解决方案--------------------
a>>>b 这种写法可能很多人都没见过
阅读