Here you can find the source of remove(Collection collection, Object object)
public static boolean remove(Collection collection, Object object)
//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; } }