This question already has an answer here:
- Pipe (|) operator in Java 7 answers
I saw recently in a code example the following:
f.setExtendedState( f.getExtendedState()|JFrame.MAXIMIZED_BOTH );
where f is a JFrame. How is this pipe operator called, what does it do and where can I find documentation about it?
Thank you Héctor
| operator is the bitwise-or operator in Java.
The result of a bitwise-or is a value with bits set in it if the corresponding bit was set in either of the operands (or both).
Here, this operation uses the value of
JFrame.MAXIMIZED_BOTH (in binary,
0000 0110) to ensure that the second to last and third to last bits are turned on, one for horizontal and one for vertical. This leaves all other bits from