What does this operatoer

This question already has an answer here:

  • Shortcut “or-assignment” (|=) operator in Java 8 answers
  • What does “|=” mean? (pipe equal operator) 6 answers

  • noti.flags |= Notification.FLAG_AUTO_CANCEL;
    

    means

    noti.flags = noti.flags | Notification.FLAG_AUTO_CANCEL;
    

    where | is the Bit wise OR operator


  • | is the bit a bit or operator
  • |= is noti.flags = noti.flags | Notification.FLAG_AUTO_CANCEL;

    noti.flags |= Notification.FLAG_AUTO_CANCEL;

    calculates the bitwise OR of the noti.flags and Notification.FLAG_AUTO_CANCEL, and assigns the result to noti.flagsd.


  • bitwise or, is the same as:

    noti.flags = noti.flags | Notification.FLAG_AUTO_CANCEL;
    

    it executes an "or" operation with the bits of the operands. Say that you have

    // noti.flags =                      0001011    (11 decimal)
    // Notification.FLAG_AUTO_CANCEL =   1000001    (65 decimal)
    
    // The result would be:              1001011    (75 decimal)
    
    链接地址: http://www.djcxy.com/p/73904.html

    上一篇: =在Java / Android中是什么意思? (位

    下一篇: 这是什么操作员