Difference between Java Enumeration and Iterator

后端 未结 10 1779
庸人自扰
庸人自扰 2020-11-27 09:47

What is the exact difference between these two interfaces? Does Enumeration have benefits over using Iterator? If anyone could elaborate, a reference article would be appre

10条回答
  •  [愿得一人]
    2020-11-27 10:10

    Both iterator and enumeration are used to retrieve the data, the difference is that enumeration can be used only for legacy classes i.e vector/stack whereas iterators can be used for the rest. Enumeration can also be used for the key set in maps.

提交回复
热议问题