The binary containment operator
is represented by the keyword
in
. It is used for the containment relation
which is on the syntactic level of relational expressions as defined
by the Java programming language.
Relational Expressions | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
The containment operator may be used for two operands of numeric type,
two operands of type boolean
,
or two operands that are each of either reference type or the
null
type.
All other cases result in a compile-time error.
The type of a containment expression is boolean
.
A containment relation e
in
s
is evaluated as follows:
The equality relation
e
==
s
is evaluated sequentially. For each yielded result, it is checked whether
it is true
. If this is the case, the sequential evaluation
is terminated, and the result
of the containment relation is true
.
If all comparisons result in false
, the result is
false
.