Here you can find the source of removeObject(List
Parameter | Description |
---|---|
l | The List from which to remove the object |
o | The object to be removed. |
public static <T> boolean removeObject(List<T> l, T o)
//package com.java2s; import java.util.List; public class Main { /**/* w ww .j a v a2 s. c o m*/ * 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; } }