Here you can find the source of removeAll(List
objects
from list
.
Parameter | Description |
---|---|
E | the element type of the list |
list | the list |
objects | a list of objects to be removed from list |
public static <E> void removeAll(List<E> list, List<? extends E> objects)
//package com.java2s; //License from project: Open Source License import java.util.Iterator; import java.util.List; public class Main { /**/*from w w w. j ava 2 s. c om*/ * Removes all <code>objects</code> from <code>list</code>. * * @param <E> * the element type of the list * @param list * the list * @param objects * a list of objects to be removed from list */ public static <E> void removeAll(List<E> list, List<? extends E> objects) { for (E object : objects) { remove(list, object); } } /** * 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(); } } } }