- HashMap:
Hash table based implementation of the Map interface. This implementation provides all of the optional map operations, and permits null values and the null key. (The HashMap class is roughly equivalent to Hashtable , except that it is unsynchronized and permits nulls.) This class makes no guarantees as to the order of the map; in particular, it does not guarantee that the order will remain constant over time.
- Hashtable:Hashtable (Java 2 Platform SE 5.0)
This class implements a hashtable, which maps keys to values. Any non-
nullobject can be used as a key or as a value.To successfully store and retrieve objects from a hashtable, the objects used as keys must implement thehashCodemethod and theequalsmethod. As of the Java 2 platform v1.2, this class has been retrofitted to implement Map, so that it becomes a part of Java's collection framework. Unlike the new collection implementations, Hashtable is synchronized
本文对比了HashMap和Hashtable两种数据结构的特点。HashMap允许使用null键和值,并且是非同步的;而Hashtable不允许使用null键或值,并且是同步的。此外,文章还介绍了这两种数据结构在Java集合框架中的地位。
9674

被折叠的 条评论
为什么被折叠?



