Here you can find the source of subtract(Collection
public static <T> List<T> subtract(Collection<T> l1, Collection<T> l2)
//package com.java2s; /******************************************************************************* * Copyright (c) 2007, 2008 Tran Nam Quang. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from ww w.j ava2s . co m * Tran Nam Quang - initial API and implementation *******************************************************************************/ import java.util.ArrayList; import java.util.Collection; import java.util.List; public class Main { /** * Returns all elements that are in <tt>l1</tt> but not in <tt>l2</tt> as * a list. */ public static <T> List<T> subtract(Collection<T> l1, Collection<T> l2) { List<T> newList = new ArrayList<T>(l1); newList.removeAll(l2); return newList; } }