The operators `==`

(equal to) and `!=`

(not equal to) are called the *equality operators*.

*EqualityExpression:* *RelationalExpression* *EqualityExpression* `==`

*RelationalExpression* *EqualityExpression* `!=`

*RelationalExpression*

The equality operators are syntactically left-associative (they group left-to-right).

However, this fact is essentially never useful. For example, `a==b==c`

parses as `(a==b)==c`

. The result type of `a==b`

is always `boolean`

, and `c`

must therefore be of type `boolean`

or a compile-time error occurs. Thus, `a==b==c`

does not test to see whether `a`

, `b`

, and `c`

are all equal.

The equality operators are commutative if the operand expressions have no side effects.

The equality operators are analogous to the relational ...

Start Free Trial

No credit card required