The Java® Language Specification, Java SE 7 Edition, Fourth Edition
by James Gosling, Bill Joy, Guy Steele, Gilad Bracha, Alex Buckley
15.21. Equality Operators
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access