Can objects be equal to each other?

Since computing an object’s equality is a time-consuming task, Java also provides a quick way of determining if an object is equal or not, using hashCode() . This returns a small number based on the object’s internal datastructure; if two objects have different hash codes, then they cannot be equal to each other .

Read more

What is an equals method?

Equals method checks to make sure that the obj argument is not null and that it references an instance of the same type as this object . If either check fails, the method returns false . The Point. Equals method calls the GetType method to determine whether the run-time types of the two objects are identical.

Read more