The Usual Methods

In Java, abstract data types may need to override three methods inherited from class Object:

You don't always have to override these methods, because the versions inherited from class Object may be good enough, but the notion of equality that's inherited from class Object is seldom the notion of equality that's appropriate for the ADT.

If you override any one of these methods, then you'll almost certainly need to override the other two as well, because all three of these methods are supposed to be consistent. If you let them become inconsistent, then parts of Java's standard libraries may fail to work correctly.

For debugging: Click here to validate.