Here you can find the source of subtract(Collection
public static <T> List<T> subtract(Collection<T> c1, Collection<T> c2)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; public class Main { /**/*w w w. j a va 2 s . com*/ * c1 - c2, does not change input collections, returns new collection (list) */ public static <T> List<T> subtract(Collection<T> c1, Collection<T> c2) { if (c1 == null) { return Collections.emptyList(); } List<T> tmp = new ArrayList<>(c1); if (c2 != null) { tmp.removeAll(c2); } return tmp; } public static <T> List<T> emptyList() { return Collections.emptyList(); } }