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> same(Collection<E> l, Collection<E> r) { if (isEmpty(l) || isEmpty(r)) return null; List<E> s = new ArrayList<E>(l); s.removeAll(r); List<E> k = new ArrayList<E>(l); k.removeAll(s); return k; } 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; } }