HashMap 和 Hashtable 有以下区别:
编号 | HashMap | Hashtable |
---|---|---|
1 | HashMap 不同步。 | Hashtable是同步的。 |
2 | HashMap 可以包含一个null 键和多个null 值。 |
Hashtable 不能包含任何null 键或null 值。 |
3 | HashMap 不是线程安全的,所以它对非线程应用程序很有用。 | Hashtable是线程安全的,可以在各个线程之间共享。 |
4 | HashMap 继承 AbstractMap 类 | Hashtable 继承 Dictionary 类。 |