相关疑难解决方法(0)

617
推荐指数
11
解决办法
57万
查看次数

HashMap#hash(int)方法的说明

有人可以向我解释静态HashMap #hash(int)方法吗?

生成均匀分布的哈希值背后的理由是什么?

/**
 * Applies a supplemental hash function to a given hashCode, which
 * defends against poor quality hash functions.  This is critical
 * because HashMap uses power-of-two length hash tables, that
 * otherwise encounter collisions for hashCodes that do not differ
 * in lower bits. Note: Null keys always map to hash 0, thus index 0.
 */
static int hash(int h) {
    // This function ensures that hashCodes that differ only by
    // constant multiples at each …
Run Code Online (Sandbox Code Playgroud)

java hash hashmap

23
推荐指数
1
解决办法
4667
查看次数

标签 统计

java ×2

equals ×1

hash ×1

hashcode ×1

hashmap ×1

overriding ×1