removeAllElements(): This method is available in java.util.Vector class of Java.
Syntax:
void java.util.Vector.removeAllElements()
This method removes all components from this vector and sets its size to zero.
Parameters: NA
Returns: NA
Exceptions: NA
Approach
Java
import java.util.Vector;public class VectorremoveAllElements {public static void main(String[] args) {Vector<String> vector = new Vector<>();vector.add("Hello");vector.add("Java");vector.add("C++");vector.add("Program");vector.removeAllElements();System.out.println(vector);}}
Output:
[]
No comments:
Post a Comment