Logical Expressions

Logical expressions work a bit differently than the previous operators and are probably not something you covered in your third-grade math class. These expressions either operate on a pair of Booleans or manipulate the individual bits of integer variables or literals. This distinction divides the logical operators into two categories:

  • Boolean operators— Only operate on boolean operands.

  • Bitwise operators— Operate on each bit in a pair of integer operands.

You have already seen in Chapter 5, "Using Expressions," how bitwise operators work. This chapter covers only the Boolean, or conditional, half of the logical expression operators. However, it is interesting to note that, with some minor exceptions, bitwise operators and conditional ...

Get Special Edition Using Java 2 Standard Edition 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.