Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Collection; public class Main { /** * Returns all objects in list1 that are not in list2 * * @param <T> Type of items in the collection * @param list1 First collection * @param list2 Second collection * @return The collection difference list1 - list2 */ public static <T> Collection<T> diff(Collection<T> list1, Collection<T> list2) { Collection<T> diff = new ArrayList<T>(); for (T t : list1) { if (!list2.contains(t)) { diff.add(t); } } return diff; } }