Get Enumeration over a HashSet in Java
Description
The following code shows how to get Enumeration over a HashSet.
Example
/*from w w w. java 2s.c o m*/
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashSet;
public class Main {
public static void main(String[] args) {
HashSet<String> hashSet = new HashSet<String>();
hashSet.add("A");
hashSet.add("B");
hashSet.add("D");
hashSet.add("E");
hashSet.add("F");
Enumeration e = Collections.enumeration(hashSet);
while (e.hasMoreElements()){
System.out.println(e.nextElement());
}
}
}
The code above generates the following result.