- Java Data Structures Resources
- Java Data Structures - Quick Guide
- Java Data Structures - Resources
- Java Data Structures - Discussion
Removing elements from a Vector
The Vector class provides removeElement() method it accepts an object and removes the specified object/element from the current Vector.
You can remove an element of Vector object using the removeElement() method by passing the index of the element that is to be removed as a parameter to this method.
Example
import java.util.Vector;
public class RemovingElements {
public static void main(String args[]) {
Vector vect = new Vector();
vect.addElement("Java");
vect.addElement("JavaFX");
vect.addElement("HBase");
vect.addElement("Neo4j");
vect.addElement("Apache Flume");
System.out.println("Contents of the vector :"+vect);
vect.removeElement(3);
System.out.println("Contents of the vector after removing elements:"+vect);
}
}
Output
Contents of the vector :[Java, JavaFX, HBase, Neo4j, Apache Flume] Contents of the vector after removing elements:[Java, JavaFX, HBase, Neo4j, Apache Flume]
Advertisements