68
Java Vector removeAllElements() Method
The removeAllElements() method of Java Vector class is used to remove all elements from the vector and set the size of the vector to zero.
Syntax
Following is the declaration of removeAllElements() method:
Parameter
This method does not accept any parameter.
Return
This method has return type void so, it does not return anything.
Exceptions
NA
Compatibility Version
Java 1.2 and above
Example 1
Output:
Size of Vector before removeAllElements() method: 3 Size of Vector after removeAllElements() method: 0
Example 2
Output:
Elements of Vector is: [3, 5, 2, 4, 1] Elements of Vector after removeAllElements(): [] Size of Vector after removeAllElements() method: 0
Next TopicJava Vector