Online Java Compiler By
JavaTpoint.com
import java.util.*; public class VectorRemoveElementExample1 { public static void main(String arg[]) { //Create an empty vector Vector
vec = new Vector<>(); // Add elements in the vector vec.add(1); vec.add(2); vec.add(3); vec.add(4); vec.add(5); vec.add(6); System.out.println("Vector element before removal: " + vec); //Remove an element vec.removeElement(5); //Checking vector and displays the element System.out.println("Vector element after removal: " + vec); } }
Output