The complted program is below.
If the Vector
has no elements, then the enumeration will
be empty, and hasMoreElements()
will evaluate to false.
import java.util.* ; class VectorEg { public static void main ( String[] args) { Vector names = new Vector( 10 ); names.addElement( "Amy" ); names.addElement( "Bob" ); names.addElement( "Chris" ); names.addElement( "Deb" ); names.addElement( "Elaine" ); names.addElement( "Frank" ); names.addElement( "Gail" ); names.addElement( "Hal" ); Enumeration enum = names.elements(); while ( enum.hasMoreElements() ) System.out.println(enum.nextElement()); } }