Remove/Delete specified element from Vector - Java Collection Framework

Java examples for Collection Framework:Vector

Description

Remove/Delete specified element from Vector

Demo Code

 
import java.util.Vector;

public class Main {

  public static void main(String[] args) {
    Vector v = new Vector();

    // Add elements to Vector
    v.add("1");/*  w  w  w . j a v  a 2  s.  c  om*/
    v.add("2");
    v.add("3");
    v.add("4");
    v.add("5");

    boolean blnElementFound = v.remove("2");
    System.out.println("Was 2 removed from Vector ? " + blnElementFound);

    System.out.println("Vector contents after remove call...");
    System.out.println(v);

    v.removeElement("3");

    System.out.println("Was 3 removed from Vector ? " + blnElementFound);
    System.out.println(v);

  }
}

Result


Related Tutorials