我正在通过 Java 对哈希表的 put 方法的实现,并遇到了这个:
// Makes sure the key is not already in the hashtable.
    Entry tab[] = table;
    int hash = key.hashCode();
    int index = (hash & 0x7FFFFFFF) % tab.length;
    for (Entry<K,V> e = tab[index] ; e != null ; e = e.next) {
        if ((e.hash == hash) && e.key.equals(key)) {
            V old = e.value;
            e.value = value;
            return old;
        }
    }
虽然我知道检查冲突需要一个键,但为什么 Java 会存储键的哈希值并检查它?