O'Reilly logo

Oracle Certified Associate, Java SE 7 Programmer Study Guide by Richard M. Reese

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Logical expressions

As with all expressions, a logical expression consists of operators and operands. In Java there are a limited number of logical operators as summarized in the following table. It is a subset of the operators listed in Chapter 2, Java Data Types and Their Usage:

Precedence

Operator

Associativity

Meaning

1

  

!

Right

Logical complement

  

   

5

<, <=, >, and >=

Left

Logical

instanceof

Left

Type comparison

6

== and !=

Left

Equality and inequality

   

10

&&

Left

Logical AND

11

||

Left

Logical OR

12

?:

Right

Conditional

   

The operands of a logical expression may be of any data type, but a logical expression will always evaluate to a true or a false value.

Note

Do not confuse ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required