The hashCode method defined by class Object does return DISTINCT integers for distinct objects.
If you don't override it you don't satisfy the hashCode contract (because different objects can be equal, and in this case their hashCode() methods should return the same value), and you are not able to locate an object in the hashtable, unless you maintain a reference to the original object. [ September 26, 2008: Message edited by: M. Piva ]
Joined: Jun 03, 2008
if you overridden equals method then , i guess no problem in not overriding the hashcode().because for every object the Object class returning unique hashcode.then we will have single bucket for every object.
Joined: Sep 26, 2008
This depends upon where you want to use it. Just for nomral purpose its sufficient to override the equal method but sometimes its necessary to override the hashcode method.