// Arup Guha
// 2/27/02
// Short Example to illustrate the use of the Vector class.
// Edited on 1/30/06 to reflect changes in Java 1.5

import java.util.*;

public class UseVectors {

  public static void main(String[] args) {

    Vector<Object> v = new Vector<Object>();  // Creates a new vector.
    v.addElement("Curly");  // Add an object
    v.insertElementAt("Larry",0); // Insert an object

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

    v.setElementAt("Moe",1); // Set an element

    // One way to print out information
    System.out.println("Here is what's in the vector:");
    for (int i=0; i<v.size(); i++) 
      System.out.println(v.elementAt(i));

    System.out.println("\nNow, here is what's in the vector:");
    // Another way to print out the information using an iterator.
    for (Object o : v) 
      System.out.println(o);

    // Insert an element and print the vector
    v.insertElementAt("Curly",1);
    System.out.println(v);

    //Access information from the vector and print it.
    String middle = (String)v.elementAt(1);
    System.out.println("Middle Guy is "+middle);
    //Now we could call String methods on middle.

    // Remove an element and add a new one.
    v.remove("Moe");
    v.addElement(new Integer(3));

    // Check if one object is in the vector.
    Integer test = new Integer(1+2);
    if (v.contains(test))
      System.out.println("Found 3.");

    // Print out final contents.
    System.out.println(v);
    
  }

}
