// file: VectorEnumeration // author: Robert Keller // purpose: Test Enumeration of a Vector's elements // description: Creates a Vector, populates it, then prints out // its elements, first using get, then using an Enumeration. import java.util.*; class VectorEnumeration { public static void main(String arg[]) { int n = 10; Vector V = new Vector(); for( int i = 0; i < n; i++ ) { V.addElement(new Integer(i)); } for( int i = V.size()-1; i >= 0 ; i-- ) { System.out.println(V.elementAt(i)); } for( Enumeration E = V.elements(); E.hasMoreElements(); ) { System.out.println(E.nextElement()); } } }