Java Enumeration.hasMoreElements()
Syntax
Enumeration.hasMoreElements() has the following syntax.
boolean hasMoreElements()
Example
In the following code shows how to use Enumeration.hasMoreElements() method.
/* w w w .j a v a2 s. c o m*/
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:
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »