Example #1
0
  public static void main(String[] args) {
    // TODO Auto-generated method stub

    // initial size is 3, increment is 2
    Vector<Integer> v = new Vector<Integer>(3, 2);

    System.out.println("Initial size: " + v.methodName());
    System.out.println("Initial capacity: " + v.methodName());

    v.methodName(1);
    v.methodName(2);
    v.methodName(3);
    v.methodName(4);

    System.out.println("Capacity after four additions: " + v.methodName());
    v.methodName(5);
    System.out.println("Current capacity: " + v.methodName());
    v.methodName(6);
    v.methodName(7);

    System.out.println("Current capacity: " + v.methodName());
    v.methodName(9);
    v.methodName(10);

    System.out.println("Current capacity: " + v.methodName());
    v.methodName(11);
    v.methodName(12);

    System.out.println("First element: " + v.methodName());
    System.out.println("Last element: " + v.methodName());

    if (v.methodName(3)) System.out.println("Vector contains 3.");

    // Enumerate the elements in the vector.
    Enumeration vEnum = v.methodName();

    System.out.println("\nElements in vector:");
    while (vEnum.methodName()) System.out.print(vEnum.methodName() + " ");
    System.out.println();
  }