📜  迭代器与枚举器 - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:00.738000             🧑  作者: Mango

代码示例2
Iterators allow the caller to remove elements from the underlying collection 
during the iteration with its remove() method. You cannot add/remove elements 
from a collection when using enumerator.
Enumeration is available in legacy classes i.e Vector/Stack etc. 
Iterator is available in all modern collection classes.
Another minor difference is that Iterator has improved method names e.g.
Enumeration.hasMoreElement() has become Iterator.hasNext(),
Enumeration.nextElement() has become Iterator.next() etc