I know how hashmaps work and how they resolve collisions. But many answers related to collisions on SO point to two reasons:
- HashCode contract - unequal objects can have the same hash code
- Underlying array size - is fixed in size and hence bucket locations may be reused (using modulo operator) when it gets full.
My assumption is that reason 2 above is also correct, as am sure of reason 1.
Only 1 question:
- Javadoc says that the hashmap uses LF and Capacity to decide when to rehash. I understand this as partly resizing the underlying array. So how is reason 2 above even possible?????
NB: This question came closest to what I want to understand. However, the accepted answer seems to discard reason 2 altogether, so it still leaves me wondering.