Skip to content

Instantly share code, notes, and snippets.

@vandershraaf
Created January 10, 2013 18:04
Show Gist options
  • Save vandershraaf/4504323 to your computer and use it in GitHub Desktop.
Save vandershraaf/4504323 to your computer and use it in GitHub Desktop.
Internal code of HashMap.get()
public V get(Object key) {
if (key == null)
return getForNullKey();
int hash = hash(key.hashCode());
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;
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment