The retainAll() method removes items from a list that are not present in a specified collection.
import public
|
The retainAll() method removes from a list all items that are not part of a specified collection.
public |
Parameter |
Description |
items |
Required: A collection containing the items to retain in the list, with all other items being removed. |
Returns: |
True if the list has been modified; false otherwise. |
Throws: |
NullPointerException occurs if the collection is null. |