![]() |
VOOZH | about |
The Java.util.Vector.clear() method is used to remove all the elements from a Vector. Using the clear() method only clears all the element from the vector and does not delete the vector. In other words, we can say that the clear() method is used to only empty an existing vector.
Syntax:
Vector.clear()
Below programs illustrate the Java.util.Vector.clear() method.
Example 1:
Elements in Vector : [Welcome, To, GFG] Vector after Operation : []
Example 2:
Vector: [10, 15, 30] The final Vector: []