![]() |
VOOZH | about |
In Java, the removeAll() method is part of the Collection interface. It is used to remove all elements from a collection that are present in another collection.
Example 1: This example demonstrates how the removeAll() method removes all elements from the first set that are also present in the second set.
Set1 before removeAll(): [Geek4, Geek3, Geek2, Geek1] Set1 after removeAll(): [Geek2, Geek1]
boolean removeAll(Collection<?> c)
Example 2: This example shows how removeAll() returns a boolean indicating whether any elements were removed from the first set by comparing it to the second set.
Set1 after removing Set2 elements from it: [Geek1] Was the collection modified? true