Written by the Fiveable Content Team โข Last updated September 2025
Verified for the 2026 exam
Verified for the 2026 examโขWritten by the Fiveable Content Team โข Last updated September 2025
Definition
The equals() method is used to compare two objects for equality. It checks if the values of the objects are the same, rather than comparing their memory addresses.
Related terms
== (double equal sign): The double equal sign is another way to compare objects for equality, but it compares their memory addresses instead of their values.
The compareTo() method is used to compare two objects based on their natural ordering. It returns an integer value that indicates whether one object is less than, equal to, or greater than another object.