How to get Enumeration over Java Vector using enumeration method of Collections class. - Java Collection Framework

Java examples for Collection Framework:Vector

Description

How to get Enumeration over Java Vector using enumeration method of Collections class.

Demo Code


import java.util.Enumeration;
import java.util.Vector;
import java.util.Collections;
 
public class Main {
 
  public static void main(String[] args) {
    Vector v = new Vector();
   // ww w.j  av  a2  s. com
    v.add("A");
    v.add("B");
    v.add("D");
    v.add("E");
    v.add("F");
 
    Enumeration e = Collections.enumeration(v);
   
    System.out.println("Enumerating through Java Vector");
    while(e.hasMoreElements())
      System.out.println(e.nextElement());
  }
}

Result


Related Tutorials