Bitwise and Logical Operators
Table 3.4 summarizes the operators that can be used on individual bits in integer primitives and in logical expressions. Bitwise operators are used in expressions with integer values and apply an operation separately to each bit in an integer. The term logical expression refers to an expression in which all of the operands can be reduced to boolean primitives. Logical operators produce a boolean primitive result.
Precedence | Operator | Operator Type | Description |
---|---|---|---|
1 | ~ | Integral | Unary bitwise complement |
1 | ! | Logical | Unary logical complement |
4 | << | Integral | Left shift |
4 | >> | Integral | Right shift (keep sign) |
4 | >>> | Integral | Right shift (zero fill) |
5 | instanceof | Object, type | Tests class membership |
6 | == | Object | Equals (same ... |
Get Java 2™ Programmer Exam Cram™ 2 (Exam CX-310-035) now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.