Java Collection First subtract(Collection firstCollection, Collection secondCollection)

Here you can find the source of subtract(Collection firstCollection, Collection secondCollection)

Description

subtract

License

Apache License

Declaration

public static Collection subtract(Collection firstCollection, Collection secondCollection) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

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

public class Main {
    public static Collection subtract(Collection firstCollection, Collection secondCollection) {
        Collection collection = new ArrayList<>();

        for (Object object : firstCollection) {
            if (!secondCollection.contains(object)) {
                collection.add(object);// w w  w. ja  v  a 2  s  .  co  m
            }
        }

        return collection;
    }
}

Related

  1. intersect(Collection firstSet, Collection secondSet)
  2. nullSafeFirstElement(Collection collection)
  3. removeFirst(Collection collection, int numToRemove)
  4. removeFirst(Collection c)
  5. sub(Collection coll, int first, int size)
  6. union(Collection firstSet, Collection secondSet)