| ^ >> >>>
<<
Places 1 bit in the result if a bit exists in one of both operands. Can be used on a boolean data type
x | y;
Places 1 bit in the result if a bit exists in one of the operands (not both)
x ^ y:
Shifts the left operand’s value to the right by the number of bits specified by the right operand
x >> 2
Shifts the left operand’s value to the right by the number of bits specified by the right operand while shifted value are filled with zeros (0)
x >>> 2
Shifts the left operand’s value to the left by the number of bits specified by the right operand
x << 2
~
Changes every bit to the opposite bit. For example, every 1 bit changes to 0 and every 0 bit changes to 1 Figure 3.4 – Bitwise Operators
~2
Logical Operators Logical Operators (known as Conditional Operators) return a boolean value based on one or more expressions. Therefore, the Logical Operator’s data type must be boolean. The following is a list of logical operators:
&& (Logical AND) operator || (Logical OR) operator ^ (Logical exclusive OR (XOR)) operator ! (Logical NOT) operator Operator &&
Description Returns true if both operands are true Returns false if one operand or both operands are false