I know that getForNullKey() resolves the null key entries in a HashMap. But will there be a scenario that there are collisions at node 0 of the HashMap. If there are multiple objects whose hashcode return zero, will they be stored in the linked list at node zero? Does getForNullKey() help in obtaining the output
private V getForNullKey() {
for (Entry<K,V> e = table[0]; e != null; e = e.next) {
if (e.key == null)
return e.value;
}
return null;
}
I am a bit confused about wht the e.value returns.
EDIT:
The doubt which I have is:Suppose we peek into a HashMap
node no 4->["Key1"|1234|"Value1"|Point to next node]--> ["Key2"|12345|"Value2"|Point to next node]
is the picture at node 4 which has collision owing to two keys that ended up in the same node.
Can such a thing happen at node zero as well ? I know how "Value2" at node 4 can be reached using get().
But can getForNullKey() help in getting to the multiple entries at node zero..if that happens. Still learning HashMap hence a curious doubt :)