Java program to get element from Vector collection at the specified index
// Java program to get element from Vector collection
// at the specified index
import java.util.*;
public class Main {
public static void main(String[] args) {
Vector < String > vec = new Vector < String > ();
int index = 2;
vec.add("CAR");
vec.add("BUS");
vec.add("BIKE");
vec.add("TRUCK");
System.out.println("Vector elements: " + vec);
System.out.println("Element at index " + index + " is: " + vec.elementAt(index));
}
}
Output
Vector elements: [CAR, BUS, BIKE, TRUCK]
Element at index 2 is: BIKE