Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { /** * Removes the first occurrence in the list of the specified object, using * object identity (==) not equality as the criterion for object presence. If * this list does not contain the element, it is unchanged. * * @param l The {@link List} from which to remove the object * @param o The object to be removed. * @return Whether or not the List was changed. */ public static <T> boolean removeObject(List<T> l, T o) { int i = 0; for (Object o1 : l) { if (o == o1) { l.remove(i); return true; } else i++; } return false; } }