Java List.removeAll(Collection <?> c)
Syntax
List.removeAll(Collection <?> c) has the following syntax.
boolean removeAll(Collection <?> c)
Example
In the following code shows how to use List.removeAll(Collection <?> c) method.
/*from w w w . j a va2s . c om*/
import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main(String args[]) throws Exception {
List<String> list = new ArrayList<String>();
list.add("A");
list.add("A");
list.add("B");
list.add("B");
list.add("C");
list.add("C");
List<String> list2 = new ArrayList<String>();
list2.add("A");
list2.add("B");
list2.add("C");
list.removeAll(list2);
System.out.println(list);
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »