What is' int kk = 2 | 3; "I mean?

I programmed in java for a while, but I did not come across a strange expression

int kk = 2 | 3;

What does '|' mean in this expression? It seems to be difficult to google.

I met him at the source

i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);

Why do we need this?

+3
source share
4 answers

This is bitwise or - each bit of the result will be set if one or both inputs have a bit set at this position. 2 - 10 in binary, 3 - 11, so the result will also be 3.

+8
source

| . 2 | 3 3, 2 10 3 11. 10 | 11 = 11.

+2

All Articles