Enumeration and Iterator, Which One Has Better Performance in Java ?

Enumeration interface is a read-only interface. It has better performance than Iterator. It is almost twice as fast as compared to an Iterator. It also uses very less memory. Also Enumeration does not have remove() method.

On the other hand, Iterator interface is safer than Enumeration, since it can check whether a collection is modified or not during iteration. If a collection is altered while an Iterator is iterating, then it throws ConcurrentModificationException.



You May Interest

What is the Difference Between JDK And JRE ?

Java How To Find The Average Of 10 Numbers Using A While Loop

How Can We Prevent a Deadlock in Java ?

What is the Difference Between wait and sleep Methods in Java ?

Why Collection Interface Doesn’t Extend Cloneable and Serializabl ...