Convert Enumeration as List - Java java.util

Java examples for java.util:List Convert

Description

Convert Enumeration as List

Demo Code


//package com.java2s;

import java.util.Enumeration;
import java.util.LinkedList;
import java.util.List;

public class Main {
    public static <T> List<T> asList(Enumeration<T> e) {
        List<T> l = new LinkedList<T>();

        while (e.hasMoreElements()) {
            l.add(e.nextElement());/*w w  w  .j  av  a 2 s .  com*/
        }

        return l;
    }
}

Related Tutorials