Retains only the elements in this collection that are contained in the specified collection.
Retains only the elements in this collection that are contained in the specified collection.In other words, removes from this collection all of its elements that are not contained in the specified collection.
This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. If it's not so contained, it's removed from this collection with the iterator's remove method.