Create a list from an enumeration - Java java.util

Java examples for java.util:List Creation

Description

Create a list from an enumeration

Demo Code


//package com.java2s;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;

public class Main {
    /**/* w  w  w .j  a  va 2  s .com*/
     * Create a list from an enumeration
     * 
     * @param e the enumeration
     * @return the list
     */
    public static List list(Enumeration e) {
        ArrayList result = new ArrayList();
        while (e.hasMoreElements())
            result.add(e.nextElement());
        return result;
    }
}

Related Tutorials