What does this sign exactly mean? |=

前端 未结 5 594
佛祖请我去吃肉
佛祖请我去吃肉 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:42

    This syntax is also available in C/C++ and other languages. It is a bitwise OR and the same as:

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

    and similar to other operators like addition, subtraction, etc. For example:

    i += 5;
    

    is the same as:

    i = i + 5;
    

提交回复
热议问题