In the above code if I override just equals method and NOT hashcode it allows me to insert duplicate objects into the Set, as expected.
In case NO Set or Map is being used by me. I just try to compare two objects (Value Object, Composite Object or Domain Object). Is there ANY specific reason() for me to maintain the equals and hashcode contract in this case.
The API doc for equal says: Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes [ November 13, 2008: Message edited by: Himalay Majumdar ]
[ November 13, 2008: Message edited by: Himalay Majumdar ]