牛魔王的故事
final Node<K,V> getNode(int hash, Object key) {
Node<K,V>[] tab; Node<K,V> first, e; int n; K k; if ((tab = table) != null && (n = tab.length) > 0 &&
(first = tab[(n - 1) & hash]) != null) { if (first.hash == hash && //检查第一个Node是否性相等
((k = first.key) == key || (key != null && key.equals(k)))) return first; if ((e = first.next) != null) { if (first instanceof TreeNode) //红黑树中查找
return ((TreeNode<K,V>)first).getTreeNode(hash, key); do { //链表查找
if (e.hash == hash &&
((k = e.key) == key || (key != null && key.equals(k)))) return e;
} while ((e = e.next) != null);
}
} return null;
}源码是通过hash和equals比较返回的