Javatpoint Logo
Javatpoint Logo

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





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback

  • Send your Feedback to feedback@javatpoint.com

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA