Bitwise operators allow us to manipulate a single "bit" in the primary data type of an integer, that is, bits. The bitwise operator performs a Boolean algebra on the corresponding bits in the two arguments and eventually produces a result.
Bitwise operations come from low-level operations in the C language. We often have to directly manipulate the hardware, we need to frequently set the hardware register bits. Java was originally designed to be embedded in the TV's top box, so this low-level operation is still preserved. However, due to the progress of the operating system, it may not be necessary to do bitwise operations too frequently.
If two input bits are 1, then the bitwise AND operator (&) generates a 1 in the output bit, otherwise the 0 is generated. If at least one of the two input bits is 1, the bitwise OR operator (|) generates a 1 in the output bit, and only if two input bits are 0, it generates a 0. If one of the two input bits is 1, but not all 1, a bitwise XOR (^, XOR, OR) generates a 1 in the output bit. A bitwise NOT (~, also called a "non" operator) is a unary operator; it operates on only one argument (all other operators are two-dollar operators). The opposite value of the input bit is generated by a bit not--if you enter 0, the output is 1; input 1, then output 0.
Both bitwise and logical operators use the same characters, but the number is different. Therefore, we can conveniently memorize the meanings of each: because "bit" is very "small", the bitwise operator uses only one character.
Bitwise operators can be used in conjunction with the equal sign (=) to combine operations and assignments: both &=,|= and ^= are legitimate (because ~ is a unary operator, it cannot be used in conjunction with =).
We treat Boolean (Boolean) types as a "unit" or "single bit" value, so it's somewhat unique. We can perform bitwise and,or and XOR, but cannot execute bitwise not (presumably to avoid confusion with logical not). For Boolean values, bitwise operators have the same effect as logical operators, except that they do not "short-circuit" in the middle. In addition, bitwise operations for Boolean values add an XOR logical operator that is not included in the list of "logical" operators. In the shift expression, we are barred from using Boolean operations, which are explained below.