Online Java Compiler By
JavaTpoint.com
import java.util.*; public class VectorSetExample3 { 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.set(15,500); //Displaying the vector element System.out.println("Vector element before set: " +vec); } }
Output