For instance, if two of your objects are always distinct
How the java runtime will understand that the object are distinct or how the jre will tell two user defined objects are equal?
The object class equals only check for references. Say for example for a Employee class objects may be treated equals depending on there dept and experience property not by looking at reference only.
Java Programmer | SCJP 1.5 | SCWCD 1.4
Stephan van Hulst
Joined: Sep 20, 2010
Exactly, and this is why you would override the equals method. A lot of classes use the equals method to see when two objects are distinct or equal. You can override this method to provide your own understanding of when two objects are equal.
Keep in mind that whenever you override equals, you *must* override hashCode as well. Take a good look at the documentation for these methods.