What does “|=” mean? (pipe equal operator)

564    Asked by AbhinayanVerma in Java , Asked on Apr 13, 2021

 I tried searching using Google Search and Stack Overflow, but it didn't show up any results. I have seen this in open source library code:

Notification notification = new Notification(icon, tickerText, when);

notification.defaults |= Notification.DEFAULT_SOUND;

notification.defaults |= Notification.DEFAULT_VIBRATE;

What does "|=" ( pipe equal operator ) mean?

Answered by Abhinayan Verma

It's a shortening for this:

  notification.defaults = notification.defaults | Notification.DEFAULT_SOUND;

And | is a bitwise OR.



Your Answer

Interviews

Parent Categories