JDK 源码中 HashMap 的 hash 方法原理

先来一段代码,看下HashMap是如何计算hash值的。 static final int hash(Object key) { int h; return (key == null) ? 0 : (h = key.hashCode()) ^ (h >>> 16); } 上述的这段代码叫做扰动函数。⼤家都知道上⾯代码⾥的key.hashCode()函数调⽤的是key
相关文章
相关标签/搜索