Online Java Compiler By
JavaTpoint.com
import java.util.*; public class VectorElementAtExample1 { public static void main(String arg[]) { //Create an empty vector Vector
vec = new Vector<>(); //Add element in the vector vec.add(1); vec.add(2); vec.add(3); vec.add(4); vec.add(5); //Get an element at the specified index System.out.println("Element at index 1 is = "+vec.elementAt(1)); System.out.println("Element at index 3 is = "+vec.elementAt(3)); } }
Output