Online Java Compiler By
JavaTpoint.com
import java.util.*; public class VectorSetElementAtExample3 { public static void main(String arg[]) { //Create an empty vector Vector
vec = new Vector<>(); //Add elements in the vector vec.add(10); vec.add(20); vec.add(30); //Set 500 at 15th index position vec.setElementAt(15,500); //Displaying the vector element System.out.println("Vector element after set: " +vec); } }
Output