Java Vector clear() MethodThe clear() method of Java Vector class is used to remove all of the elements from the vector which is in use. Syntax:Following is the declaration of clear() method: Parameter:This method does not accept any parameter. Returns:This method has return type void so, it does not return any value. Exceptions:NA Compatibility Version:Java 1.2 and above Example 1:Test it NowOutput: Size of Vector before clear() method: 3 Size of Vector after clear() method: 0 Example 2:Test it NowOutput: Elements of Vector is: [3, 5, 2, 4, 1] Elements of Vector after clear(): [] Next TopicJava Vector |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India