What does this sign exactly mean? |=

前端 未结 5 577
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-13 05:18

|=

I\'m curious to learn about this operator, I\'ve seen this notation used while setting flags in Java.

for example:

notification.flags |=         


        
5条回答
  •  没有蜡笔的小新
    2021-01-13 05:39

    It is equivalent to

    notification.flags = notification.flags | Notification.FLAG_AUTO_CANCEL;
    

    where | is bitwise OR operator which OR the two variables bit-by-bit.

    It is well known by itself. There are also +=, -=, *=, /=, %=, &=, ^=.

提交回复
热议问题