Operators

Operators compose identifiers and literals into larger expressions. Operators can be logical operators, arithmetic operators, or comparison operators.

Logical Operators

The logical operators are NOT, AND, and OR. These are in precedence order. These have the usual boolean logic semantics. If a logical operator is applied to header fields or properties whose value is null, then the following rules apply:

  • ANDing a null value with a false value evaluates to false; ANDing a null with a true or null value evaluates to a null (or unknown) value.

  • ORing a null value with a true value evaluates to true; ORing a null with a false or a null value evaluates to a null (or unknown) value.

  • Applying NOT to a null value evaluates to a null (or unknown) value.

Arithmetic Operators

The arithmetic operators, in precedence order, are + and - (unary), * and /, + and - (binary). These have the usual arithmetic semantics. Any arithmetic operator that is applied to one or more null values evaluates to a null value.

Comparison Operators

The comparison operators can be loosely grouped into equality comparisons and range comparisons. The basic equality comparison operators, in precedence order, are =, >, >=, < , <=, and < >. These binary operators have to be applied to two values of the same type, else the expression always evaluates to false. If either value is null, the result of the comparison is null. There are also the equality operators IS NULL and IS NOT NULL to compare a value ...

Get Java Enterprise in a Nutshell, Second 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.