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:
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.
Java 1.2 and above
Example 1Test it Now
Vector: [1, 2, 3, 4, 5] Removing all the elements Size of the vector: 0
Example 2Test it Now
Vector: [A, B, C, 10, 20] Collection removed Final Vector: [10, 20]