This is a very basic question to the group for better understanding of Hashset
behavior, when the equals()
method is not overridden.
First I have created an Employee
class and overrode its hashcode()
such that it will return int 1 every time. (to ensure collision).
Next in main method, I've created 4/5 employee objects and pushed into the hashset
. Now while I iterate over the hashset
, I can see all inserted objects there. Can anyone please explain this behavior, specially how the chaining is happening here (please remember I didn't override the equal method)?