Online Java Compiler By
JavaTpoint.com
import java.util.*; public class VectorSetExample2 { 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 set: " +vec); //Set JavaTpoint at 3rd index position vec.set(3,"JavaTpoint"); //Displaying the vector element again System.out.println("Vector element after set: "+vec); } }
Output