Java tutorial
//package com.java2s; import java.util.*; public class Main { public static <T> Collection<T> subtract(Collection<T> list1, Collection<T> list2, Comparator<? super T> comp) { Collection<T> removedList = new ArrayList<T>(); for (T item1 : list1) { for (T item2 : list2) { if (comp.compare(item1, item2) == 0) { removedList.add(item1); } } } list1.removeAll(removedList); return list1; } }