![]() |
VOOZH | about |
The Java.util.Vector.removeAllElements() method is used to removes all components from this Vector and sets its size to zero. Syntax:
Vector.removeAllElements()
Parameters: The method does not take any parameter
Return Value: The function does not returns any value.
Below programs illustrate the Java.util.Vector.removeAllElements() method.
Example 1:
Vector: [Welcome, To, Geeks, 4, Geeks] The final Vector: []
Example 2:
Vector: [10, 15, 30, 20, 5] The final Vector: []
Time complexity: O(n). // n is the size of the vector.
Auxiliary space: O(1)