Java Utililty Methods Collection Remove

List of utility methods to do Collection Remove

Description

The list of methods to do Collection Remove are organized into topic(s).

Method

voidremoveAll(Collection left, Collection right)
remove All
if (left != null && right != null) {
    left.removeAll(right);
ListremoveAll(Collection source, Collection remove)
remove All
List<T> list = new ArrayList<>(source);
list.removeAll(remove);
return list;
booleanremoveAll(final Collection c, final Object... array)
remove All
boolean result = false;
for (final Object element : array) {
    result |= c.remove(element);
return result;
ListremoveAll(final Collection collection, final Collection remove)
Removes the elements in remove from collection.
final List<E> list = new ArrayList<E>();
for (final E obj : collection) {
    if (!remove.contains(obj)) {
        list.add(obj);
return list;
booleanremoveAll(final Collection collection, final T... objects)
Removes all objects from the specified list.
boolean result = false;
for (final T object : objects) {
    result |= collection.remove(object);
return result;
voidremoveAllElements(Collection data, T value)
remove All Elements
if (data == null)
    return;
while (data.contains(value))
    data.remove(value);
booleanremoveAllFromCollection(Collection collection, Collection toRemove)
Removes each element in given collection one by one from specified collection.
boolean changed = false;
for (Object obj : toRemove) {
    changed |= collection.remove(obj);
return changed;
booleanremoveAllFromSet(AbstractSet collection, Collection toRemove)
remove All From Set
boolean result = false;
for (Object o : toRemove)
    result |= collection.remove(o);
return result;
TremoveAny(Collection collection)
remove Any
T item = null;
if (collection.iterator().hasNext())
    item = collection.iterator().next();
return item;
StringremoveArrayMarkerFromCollectionToString(Collection col)
remove Array Marker From Collection To String
return col.toString().replaceAll("\\[", "").replaceAll("\\]", "");