0

So I am learning Java right now and I am following a tutorial where a guy uses the line...

int action = event.getAction() & MotionEvent.ACTION_MASK;

I have never really seen anything like this before, how does that "&" work in there? Does it somehow combine the 2 values into a single value, like...

int x = 5 & 1; //would that be 6?

It just makes no sense to me, and I have tried searching google but all I get is random variable assignment tutorials with keywords like "final", "static", and such. I understand what those are, just not that & symbol when assigning a value to a variable. Thank you.

Neglected Sanity
  • 1,770
  • 6
  • 23
  • 46
  • Sorry if this sounds as a repetition of what you read. It is a binary bit operator. – rgv Mar 26 '18 at 18:55
  • this is for C, but it works the same in java https://en.wikipedia.org/wiki/Bitwise_operations_in_C#Bitwise_AND_& – DutChen18 Mar 26 '18 at 18:57

0 Answers0