Slightly more precisely (or pedantically).
Equals is used to see whether the details of two objects are the same. If you are using a class seriously, rather than as a training exercise, you ought to override the equals method.
You should return true if and only if
The two objects are from exactly the same classand all their fields have the same values. As a shortcut, you can return true if object1 == object2 because if they are the same object, they ought to have the same features.
If you override the equals method, you must override the hashcode method too, because two objects which return true to their equals method must return the same hashcode. More details in the java.lang.Object class in
the API specification. [ June 27, 2006: Message edited by: Campbell Ritchie ]