My understanding is that we can not add duplicate objects to HashSets. In the following code Dog class is provided with equals and hashcode methods so that duplicate dogs should not get added to HashSet . But I am able to add equal objects to HashSet ? What is that I am missing ?
Thanks for pointing out the mistake on hashCode / hashcode . Because of the typo ,Effectively in my code there was no hashCode . But there was equals method.
In such scenario , How the duplicates are identified . Are the duplicates identified based on equals method or based on default hashCode method ?