import java.util.*; public class Q1 { public static void main(String[] args) { Vector v = new Vector(3); v.addElement("a"); v.addElement("b"); v.insertElementAt("c", 1); v.addElement("d"); v.removeElementAt(2); // The capacity() method returns the size of the underlying array. System.out.println("Size of array: " + v.capacity()); for (int i = 0; i < v.capacity(); i++) { // It is illegal to access an element of the Vector at an index // greater than or equal to its size, regardless of its capacity. if (i < v.size()) { System.out.println("" + i + ": " + v.elementAt(i)); } else { System.out.println("" + i + ": "); } } return; } }