Here you can find the source of remove(List
object
from the given list
, comparing each element in the list with equals
.
Parameter | Description |
---|---|
list | a list |
object | an object to be removed from the list |
public static <E> void remove(List<E> list, E object)
//package com.java2s; //License from project: Open Source License import java.util.Iterator; import java.util.List; public class Main { /**//w w w. j av a 2s. c o m * Removes the given <code>object</code> from the given <code>list</code>, * comparing each element in the list with <code>equals</code>. * * @param list * a list * @param object * an object to be removed from the list */ public static <E> void remove(List<E> list, E object) { for (Iterator<E> it = list.iterator(); it.hasNext();) { if (it.next().equals(object)) { it.remove(); } } } }