Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.Collection; import java.util.List; public class Main { public static <E> Collection<E> diffLeft(Collection<E> l, Collection<E> r) { if (isEmpty(l) || isEmpty(r)) return l; List<E> s = new ArrayList<E>(l); s.removeAll(r); r.removeAll(l); return s; } public static boolean isEmpty(Collection<? extends Object> c) { return c == null || c.size() == 0; } public static boolean isEmpty(Object[] objs) { return objs == null || objs.length == 0; } }