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 anull
value with afalse
value evaluates tofalse
;AND
ing anull
with atrue
ornull
value evaluates to anull
(or unknown) value.OR
ing anull
value with atrue
value evaluates totrue
;OR
ing anull
with afalse
or anull
value evaluates to anull
(or unknown) value.Applying
NOT
to anull
value evaluates to anull
(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.