Online Java Compiler By
JavaTpoint.com
import java.util.*; public class VectorRemoveElementExample2 { 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 remove: "+vec); //Removing the "Rahul" from the Vector boolean b = vec.removeElement("Rahul"); System.out.println("Is the removal successful?? "+b); //Printing the elements of the Vector System.out.println("The elements of the Vector after remove: "+vec); } }
Output