Java tutorial
//package com.java2s; import java.util.*; public class Main { public static <T> List<T> getLeftDiff(List<T> list1, List<T> list2) { if (isEmpty(list2)) { return list1; } List<T> list = new ArrayList<T>(); if (isNotEmpty(list1)) { for (T o : list1) { if (!list2.contains(o)) { list.add(o); } } } return list; } public static boolean isEmpty(Map map) { return !isNotEmpty(map); } public static boolean isEmpty(Collection<?> collection) { return !isNotEmpty(collection); } public static boolean isNotEmpty(Map map) { return map != null && map.size() > 0; } public static boolean isNotEmpty(Collection<?> collection) { return collection != null && collection.size() > 0; } }