Java tutorial
//package com.java2s; import java.util.Collection; import java.util.Iterator; public class Main { public static <T> boolean removeIdentity(Collection<T> c, T e) { for (Iterator<T> i = c.iterator(); i.hasNext();) if (i.next() == e) { i.remove(); return true; } return false; } }