Java Vector clear() Method
The clear() method of Java Vector class is used to remove all of the elements from the vector which is in use.
Following is the declaration of clear() method:
This method does not accept any parameter.
This method has return type void so, it does not return any value.
Java 1.2 and above
Example 1:Test it Now
Size of Vector before clear() method: 3 Size of Vector after clear() method: 0
Example 2:Test it Now
Elements of Vector is: [3, 5, 2, 4, 1] Elements of Vector after clear():