Enumeration Interface in java.util: hasMoreElements, nextElement method

Enumeration Interface is used to access objects one by one in a collection of objects. It is a part of the legacy interface in java.util. All the legacy interfaces and classes are synchronized by default. Methods defined by Enumeration Interface:

hasMoreElements( ) method: It returns true if there are elements to enumerate, otherwise false.


boolean hasMoreElements( )

nextElement( ) method: It is used to return next object in enumeration as a generic Object reference.


Object nextElement( )

Leave a Reply