Bitwise operators are used for the operation on bits in Java. Bitwise operators could be used for operations on int, short, long, byte. and char types.
Here are the bitwise operators in Java:
- & For bitwise AND
- | For bitwise OR
- ~ For bitwise unary NOT
- ^ For bitwise exclusive OR
- >> For shift of bits to right for a desired number of times.
- << For shift of bits to left for a desired number of times.
- >>> For right shift zero fill
- &= For bitwise AND assignment
- |= For bitwise OR assignment
- ^= For bitwise exclusive OR assignment
- >>= For right shift assignment
- >>>= For right shift zero fill assignment
- <<= For left shift assignment