我正在查找这两个类之间的区别,这一点出现在很多答案中,此博客是来源:http://javarevisited.blogspot.com/2010/10/difference- Between-hashmap-and.html http://javarevisited.blogspot.com/2010/10/difference-between-hashmap-and.html
但我并不完全明白。
有人可以详细说明一下吗?也许有一个例子?
感谢您的关注!
快速失败意味着当您在迭代过程中尝试修改内容时,它将失败并抛出 ConcurrentModificationException。
Set keys = hashMap.keySet();
for (Object key : keys) {
hashMap.put(someObject, someValue); //it will throw the ConcurrentModificationException here
}
对于哈希表枚举:
Enumeration keys = hashTable.keys();
while (keys.hasMoreElements()) {
hashTable.put(someKey, someValue); //this is ok
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)