Java Collection Remove remove(Collection collection, Object object)

Here you can find the source of remove(Collection collection, Object object)

Description

remove

License

Open Source License

Declaration

public static boolean remove(Collection collection, Object object) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;
import java.util.Iterator;

public class Main {
    public static boolean remove(Collection collection, Object object) {
        boolean removed = false;
        Iterator it = collection.iterator();
        while (it.hasNext()) {
            Object o = it.next();
            if (o.equals(object)) {
                removed = true;/* ww  w .  ja  va2  s  . c o  m*/
                it.remove();
                break;
            }
        }

        return removed;
    }
}

Related

  1. getItemsStartingWith(Collection items, String prefix, boolean removePrefix)
  2. getRemovedItems(Collection oldValues, Collection newValues)
  3. minus(Collection primaryCollection, Collection toBeRemovedCollection, Collection target)
  4. remove(Collection c, Object o)
  5. remove(Collection p_collection, int p_index, int p_numberOfObjects)
  6. remove(Collection col, T value)
  7. remove(Collection collection, final int count)
  8. remove(Collection collection, T... items)