Java Collection Subtract subtract(final Collection a, final Collection b)

Here you can find the source of subtract(final Collection a, final Collection b)

Description

subtract

License

Apache License

Declaration

public static <T> List<T> subtract(final Collection<T> a, final Collection<T> b) 

Method Source Code

//package com.java2s;
/**//  ww w  .j a  v  a  2  s .  c om
 * Copyright (c) 2005-2012 springside.org.cn
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */

import java.util.ArrayList;
import java.util.Collection;

import java.util.Iterator;
import java.util.List;

public class Main {
    public static <T> List<T> subtract(final Collection<T> a, final Collection<T> b) {
        ArrayList<T> list = new ArrayList<T>(a);
        for (Iterator it = b.iterator(); it.hasNext();) {
            list.remove(it.next());
        }
        return list;
    }
}

Related

  1. subtract(Collection c1, Collection c2)
  2. subtract(Collection l1, Collection l2)
  3. subtract(Collection l1, Collection l2)
  4. subtract(final Collection a, final Collection b)
  5. subtract(final Collection a, final Collection b)
  6. subtract(final Collection a, final Collection b)
  7. subtractCollections(Collection collection1, Collection collection2)