Can someone please explain me the code for the hashmap get(key) method?
Inside the get(Object key) method of Java , there is a piece of code which
I am not able to understand.
I know how the get(key) method works even in case when hashcode is same
for two object.
But the below piece of code I am unable to understand.
for (Entry<K,V> e = table[indexFor(hash, table.length)];
e != null;
e = e.next) {
Object k;
if (e.hash == hash && ((k = e.key) == key || key.equals(k)))
return e.value;
}
Can someone explain. Thanks
No comments:
Post a Comment