Possible Duplicate:
Overriding equals and hashCode in Java
All,
I have defined my class and which to override equals() and hashCode () methods as well. But I have no idea of what specifically these methods should be implemented for my own class. Can anyone please shed some light on the implementation of these methods for custom classes?
You say you already know which one of your custom classes need to override hashCode/equals? Then you also know what attributes (global variables) determine equality of each class.
When you know these attributes you can implement hashCode/equals either manually or by generating the methods using a modern IDE such as Eclipse, NetBeans, etc. In Eclipse there’s an option named “Generate hashCode() and equals()” under the “Source” menu