Both are used to traverse a sequence of elements.
>> Iterator is new while Enumeration is old.
>> Iterator take the place of Enumeration in Java collections framework.
>> Iterator iterates over a collection while Enumeration iterates over Vector, key and value of Hashtable.
>> Iterator allows to remove elements during the iteration while Enumeration is read only
>> Iterator improves the method names
本文对比了Java中迭代器(Iterator)与枚举(Enumeration)的区别:迭代器是Java集合框架的一部分,取代了较旧的枚举;迭代器允许在遍历过程中移除元素而枚举只读;迭代器改进了方法命名。
1353

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



