Online Java Compiler By
JavaTpoint.com
import java.util.*; public class VectorRemoveElementAtExample2 { public static void main(String arg[]) { //Create an empty Vector Vector
vec = new Vector<>(); //Add elements to the Vector vec.add("Rahul"); vec.add("Karan"); vec.add("Rahul"); vec.add("Rohan"); //Printing the elements of the Vector System.out.println("The elements of a Vector before removal: "+vec); //Removing the element at index 2 vec.removeElementAt(2); //Printing the elements of the Vector again System.out.println("The elements of a vector after removal: "+vec); } }
Output