1.HashTable extends Dictionary implements Map
HashMap
extends AbstractMap implements Map
2.HashTable的方法是线程同步的。
HashMap不是。可以用Collections.synchronizedMap(Map) 同步MAP。
3.HashTable不允许null值(key和value都不可以),如果有编译的时候不会有异常,运行的时候会报空指针异常。
HashMap允许null值(key和value都可以)。用containsKey(key)来判断map中是否存在某个键。
4.HashTable使用Enumeration遍历。
HashMap使用Iterator遍历。
5.HashTable中hash数组默认大小是11,增加的方式是 old*2+1。
HashMap中hash数组的默认大小是16,而且一定是2的指数。
6.哈希值的使用不同:HashTable直接使用对象的hashCode。
HashMap重新计算hash值,而且用与代替求模。