1、两者继承的直接父类不同:Hashtable继承自Dictiionary,HashMap继承自AbstractMap,这一区别可以通过两者的源码明显地看到:public class HashMapextends AbstractMapimplements Map, Cloneable, Serializable
public class Hashtableextends Dictionaryimplements Map, Cloneable, java.io.Serializable2、Hashtable的put方法如下:public synchronized V put(K key, V value) {
// Make sure the value is not null
if (value == null) {
throw new NullPointerException();
}
// Makes sure the key is not already in the hashtable.
Entry tab[] = table;
int hash = key.hashCode();
int index = (hash & 0x7FFFFFFF) % tab.length;
for (Entry e = tab[in
...
继续阅读
(47)