Create Java ArrayList From Enumeration - Java Collection Framework

Java examples for Collection Framework:ArrayList

Description

Create Java ArrayList From Enumeration

Demo Code


import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Vector;
 
public class Main {
 
  public static void main(String[] args) {
    Vector v = new Vector();
   // ww  w  .  j a  v a2 s.  c  o  m
    v.add("A");
    v.add("B");
    v.add("D");
    v.add("E");
    v.add("F");
   
    System.out.println("Vector contains : " + v);
   
    Enumeration e = v.elements();
   
    ArrayList aList = Collections.list(e);
    System.out.println("Arraylist contains : " + aList);
  }
}

Result


Related Tutorials