# 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:

• `AND`ing a `null` value with a `false` value evaluates to `false`; `AND`ing a `null` with a `true` or `null` value evaluates to a `null` (or unknown) value.

• `OR`ing a `null` value with a `true` value evaluates to `true`; `OR`ing 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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.