Here you can find the source of difference(List
public static <T1> void difference(List<T1> lst1, List<T1> lst2)
//package com.java2s; import java.util.*; public class Main { public static <T1> void difference(List<T1> lst1, List<T1> lst2) { for (T1 elem : lst2) { lst1.remove(elem);//from w w w. j a va2 s . c o m } } }