【JAVA】八 HableMap HashTable
本篇作为hashmap hashtable的一个小的简单介绍,我透过下面的表格大致的分析了这两个类,
如果你想深入了解的话可以点击下方的连接,会跳转到相应的介绍,那里介绍的更加详细些 .
功能 | HashMap | HashTable |
---|---|---|
接口 | Map, Cloneable, Serializable | Map, Cloneable, java.io.Serializable |
父类 | AbstractMap | Dictionary |
初始大小 | 16 | 11 |
初始阀值因子 | 0.75f | 0.75f |
最大长度 | 1 << 30 ( 1073741824 ) | Integer.MAX_VALUE - 8 ( 2147483639 ) |
扩容 | 原始大小 * 2 | 原始大小 * 2 + 1 |
记录长度属性 | size | count |
key value | 允许null key 允许null value | 不允许 null key 不允许 null value |
线程同步 | 不安全 | 安全 |
hash方法不同 | h ^= (h >>> 20) ^ (h >>> 12); return h ^ (h >>> 7) ^ (h >>> 4); | hashSeed ^ k.hashCode() |
Entry 内部类 | implements Map.Entry | implements Map.Entry |
详细介绍 | http://blog.csdn.net/maguochao_mark/article/details/51496513 | http://blog.csdn.net/maguochao_mark/article/details/51585652 |