Java Operator: |= -


this question has answer here:

i came across following line inside sourcecode.

int sequ |= element.sequence 

what operator |= mean ? haven't seen before.

=| compound assignment operator, similar +=, -=, /=, or *=, bitwise or instead.

this equivalent to:

sequ = (int) (sequ | element.sequence); 

where | bitwise or operation, meaning independently ors bits in left operand in right operand, result. cast not necessary if element.sequence int.

note: original code wouldn't make sense:

int sequ |= element.sequence 

you can't declare there , , or else. need have been declared , assigned before, such in:

int sequ = 0; /* or other value */ sequ |= element.sequence; 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -