Home » Java Vector removeAllElements() Method with Examples

Java Vector removeAllElements() Method with Examples

by Online Tutorials Library

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

Test it Now

Output:

Size of Vector before removeAllElements() method: 3  Size of Vector after removeAllElements() method: 0  

Example 2

Test it Now

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

You may also like