3.3.5 λÔËËã & ÒÆÎ»ÔËËã



The bitwise operators allow you to manipulate individual bits in an integral primitive data type. You can perform a bitwise AND, OR and XOR, but you can't perform a bitwise NOT (presumably to prevent confusion with the logical NOT).

The shift operators can be used solely with primitive, integral types.

If you shift a char, byte, or short, it will be promoted to int before the shift takes place, and the result will be an int. Only the five low-order bits of the right-hand side will be used.
If you're operating on a long, long will be the result. Only the six low-order bits of the right-hand side will be used so you can't shift more than the number of bits in a long.

Next Page