Return | Method | Summary |
---|---|---|
static<T> Enumeration<T> | enumeration(Collection<T> c) | Returns an enumeration over the specified collection. |
static<T> ArrayList<T> | list(Enumeration<T> e) | Returns an array list containing the elements returned by the specified enumeration in the order they are returned by the enumeration. |
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Vector;
public class Main {
public static void main(String args[]) throws Exception {
Vector<String> v = new Vector<String>();
v.add("a");
v.add("b");
v.add("java2s.com");
Collection<String> col = v;
Enumeration<String> e = Collections.enumeration(col);
for (; e.hasMoreElements();) {
Object o = e.nextElement();
System.out.println(o);
}
}
}
The output:
a
b
java2s.com
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<String> v = new Vector<String>();
v.add("A");
v.add("B");
v.add("D");
v.add("E");
v.add("java2s.com");
System.out.println(v);
Enumeration<String> e = v.elements();
ArrayList<String> aList = Collections.list(e);
System.out.println(aList);
}
}
The output:
[A, B, D, E, java2s.com]
[A, B, D, E, java2s.com]
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |