Here you can find the source of removeAllFromCollection(Collection collection, Collection toRemove)
Parameter | Description |
---|---|
collection | collection to remove from. |
toRemove | collection containing elements to remove. |
public static boolean removeAllFromCollection(Collection collection, Collection toRemove)
//package com.java2s; import java.util.Collection; public class Main { /**//from ww w. ja v a 2 s . c om * Removes each element in given collection one by one from specified collection. * * @param collection collection to remove from. * @param toRemove collection containing elements to remove. * @return True if original collection is changed, false otherwise. */ public static boolean removeAllFromCollection(Collection collection, Collection toRemove) { boolean changed = false; // loop to remove each of element for (Object obj : toRemove) { changed |= collection.remove(obj); } return changed; } }