List.removeAll(Collection <?> c) has the following syntax.
boolean removeAll(Collection <?> c)
In the following code shows how to use List.removeAll(Collection <?> c) method.
// w w w . ja v a2 s . com 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.