HashMap 中hash table 定位算法: int hash = hash(key.hashCode()); int i = indexFor(hash, table.length); 其中indexFor和hash源码如下: /** * Applies a supplemental hash function to a given hashCode, which * defends against poor quality hash functions. This is critica…
JDK7: public final int hashCode() { return Objects.hashCode(getKey()) ^ Objects.hashCode(getValue()); } /** * Retrieve object hash code and applies a supplemental hash function to the * result hash, which defends against poo…