Online Java Compiler By
JavaTpoint.com
import java.util.*; public class VectorSetElementAtExample2 { public static void main(String arg[]) { //Create an empty vector Vector
vec = new Vector
(); //Add elements in the vector vec.add("Java"); vec.add("Android"); vec.add("Python"); vec.add("COBOL"); //Displaying the vector element System.out.println("Vector element before setElementAt(): " +vec); //Set "JavaTpoint" at 3rd index position vec.setElementAt("JavaTpoint", 3); //Displaying the vector element again System.out.println("Vector element after setElementAt(): "+vec); } }
Output