Delete comment from: Javarevisited
Yadu said...
Nice explanation of internal logic of HashMap. But I think this focuses on pre Java 5.
It uses HashMap.Entry for storing key-value not linked list. Very nice and clever use of Entry object.
for (Entry e = table[i]; e != null; e = e.next) {
Object k;
if (e.hash == hash && ((k = e.key) == key || key.equals(k))) {
V oldValue = e.value;
e.value = value;
e.recordAccess(this);
return oldValue;
}
}
May 24, 2012, 11:45:03 AM
Posted to How HashMap works in Java?