During insert the HashSet
first calls the hashCode
and looks in which bucket the new value belongs to. It sees that there are already three entries (all with the hashCode()
25
).
So it then compares by using equals()
. And because there are 3 entries it has to check all entries causing to call equals()
3 times.