Javatpoint Logo
Javatpoint Logo

Java Vector removeAll() Method

The removeAll() method of Java Vector class deletes all the elements from the vector that are present in the specified collection.


Following is the declaration of removeAll() method:


Parameter Description Required/Optional
c It is a collection of elements which will be removed from the vector. Required


The removeAll() method returns true if the vector changed as a result of the call.


NullPointerException- This method has thrown an exception if the vector contains one or more null elements and the specified collection does not support null elements or if the specified collection is null.

Compatibility Version

Java 1.2 and above

Example 1

Test it Now


Vector: [1, 2, 3, 4, 5]
Removing all the elements
Size of the vector: 0

Example 2

Test it Now


Vector: [A, B, C, 10, 20]
Collection removed
Final Vector: [10, 20]

Next TopicJava Vector

Youtube For Videos Join Our Youtube Channel: Join Now


  • Send your Feedback to

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA