Hello J World wrote:
Hi, In spite of overriding equals, why HashMap is allowing duplicate entries...?
you should override hashCode method too. because HashMap entry checks the equality of both hashCode and equals . if any one fails then HashMap add the new entry value. @see HashMap#put(K, V)
<edit> also your overridden equals method can be fragile . have a look how to override an equals method</edit>