Enumeration

 Enumeration

  • this cursor is used to access the elements of the Collection only in the forward direction.
  • this is legacy cursor can be applied only for legacy classes like Vector, Stack and Hashtable.
  • Enumeration is also an interface and we can not create objects directly.
  • If we want to create an object for Enumeration we have to use a legacy method called the elements() method.

Creation of Enumeration:

Enumeration e = v.elements();

here elements() method internally creates and returns an object of a class that implements the Enumeration interface.

Methods

  • boolean hasMoreElements()
  • Object nextElement()

Example:


Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.