Comparison Operators

The comparison operators are used to compare primitive values or object references. They are organized into three subgroups: the relational operators, the equality operators, and the instanceof operator. The relational operators are only defined for numeric values, and the instanceof operator is only defined for object references.

The Relational Operators

The four relational operators are < (less than), <= (less than or equal to), > (greater than), and >= (greater than or equal to). These operators follow their mathematical definitions and produce a boolean value as their result. However, you should note that any relational expression with the NaN value evaluates to false.

The Equality Operators

The equality operators consist ...

Get Sun Certification Training Guide (310-025, 310-027): Java™ 2 Programmer and Developer Exams 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.