- Java Data Structures Resources
- Java Data Structures - Quick Guide
- Java Data Structures - Resources
- Java Data Structures - Discussion
Clearing the elements of the Vector
You can remove all the elements in the given vector using the clear() method.
Example
import java.util.Vector;
public class ClearingElements {
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("Elements of the vector :"+vect);
vect.clear();
System.out.println("Elements of the vector after clearing it :"+vect);
}
}
Output
Elements of the vector :[Java, JavaFX, HBase, Neo4j, Apache Flume] Elements of the vector after clearing it :[]
Advertisements