HashTable 和HashMap区别
HashTable最早的版本是JDK1.1 ,HashMap最早版本是1.2
HashTable继承的是Dictionary抽象类 , HashMap继承的是AbstractMap
HashTable是线程安全的,HashMap 是线程不安全
HashTable没有contains方法
HashTable key value 都不能为Null,HashMap key value可以为Null
HashTable散列算法是取余,HashMap 是按位与(取模算法)
HashTable初始化默认大小是11,HashMap初始化默认大小是16
这里还需要考虑为什么取余算法 默认就是11,每次扩容都是*2,
应该和HashMap扩容有关
HashTable 内部迭代实现用的是枚举迭代(Enmeration,第一代迭代器),HashMap内部迭代实现用的迭代器(Iterator)
HashTable 内部Node是链表结构,HashMap 1.8新特性 内部Node对象链表长度超过8后,会变更为红黑树,树节点小于6的时候,会转换成链表