JAVA Enumeration Interface

Enumeration is an interface introduced in 1.0V(legacy) used to retrieve data one by one
from Vector only. Using Enumeration object we will do this. There is a method elements()
invoking by Vector object, then we will get Enumeration object.

Enumeration e = v.elements();

Here v is any Vector object.

Enumeration defines the following 2 methods like:

1. public boolean hasMoreElements();

Tests if this enumeration contains more elements. It returns true if and only if this
enumeration object contains at least one more element to provide; otherwise it returns false.

2. public Object nextElement();

Returns the next element of this enumeration if this enumeration object has at least one more
element to provide. It returns the next element of this enumeration. It throws
NoSuchElementException - if no more elements exist.

import java.util.*;
class EnumerationExample
             public static void main(String[] args)
                Vector v=new Vector();
                Enumeration e=v.elements();
                     Integer i=(Integer)e.nextElement();

Our Services:

Java Training | Python Training | Machine Learning with Python Training | Deep Learning with Python Training | Data Science with Python Training | Projects

Silansoftware Pvt.Ltd, BBSR
Call to: 0674-2361252