/**
 * TestVector.java -- This is an application/main class that illustrates how
 * to use a vector.
 *
 * JDEP 183H Fall 2006
 * @author Leen-Kiat Soh
 * @version 1.0
 */

import java.util.*;

class TestVector {

   public static void main (String[] args)  {

      Vector myVector = new Vector();
      Jedi luke = new Jedi(10,"Luke");
      myVector.addElement(luke);
      myVector.addElement("What");   // LOOK!  I can add elements of different
                                     // types

      System.out.println("Size of myVector = " + myVector.size());

      Vector another = new Vector();
      another.addElement("what is this?");
      another.addElement("how do I do this?");
      another.addElement("this is a vector!");
      another.addElement("this is better than array?");

      System.out.println("Size of another = " + another.size());

      for (int i = 0; i < another.size(); i++)
         System.out.println(another.elementAt(i));

      another.removeElementAt(2);

      // automated "resizing"
      System.out.println("After removal: Size of another = " + another.size());

      // this is to show that Vector automatically "packs" the elements
      for (int i = 0; i < another.size(); i++)  
         System.out.println(another.elementAt(i));
      }

}


