Online Java Compiler By
JavaTpoint.com
import java.util.*; public class VectorInsertElementAtExample1 { public static void main(String arg[]) { //Create an empty vector Vector
vec = new Vector<>(); //Add element in the vector vec.add(10); vec.add(20); vec.add(30); vec.add(40); vec.add(50); //Printing the element System.out.println("Element in vector before insertion = "+vec); //Insert the element at 2nd position vec.insertElementAt(700, 2); System.out.println("Element in vector after insertion = "+vec); } }
Output