Java Collection Remove removeAll(Collection collection, Collection remove)

Here you can find the source of removeAll(Collection collection, Collection remove)

Description

remove All

License

Apache License

Declaration

public static <T> List<T> removeAll(Collection<T> collection, Collection<T> remove) 

Method Source Code


//package com.java2s;
//License from project: Apache 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> removeAll(Collection<T> collection, Collection<T> remove) {
        List<T> list = new ArrayList<T>();
        for (Iterator<T> iter = collection.iterator(); iter.hasNext();) {
            T obj = iter.next();/*from   w ww  . ja v a 2s .  c  o  m*/
            if (remove.contains(obj) == false) {
                list.add(obj);
            }
        }
        return list;
    }
}

Related

  1. removeAll(Collection c, Iterable elts)
  2. removeAll(Collection c, Object e)
  3. removeAll(Collection c, T... array)
  4. removeAll(Collection c, T... array)
  5. removeAll(Collection ret, Object[] elements)
  6. removeAll(Collection collection, T... elementsToRemove)
  7. removeAll(Collection left, Collection right)
  8. removeAll(Collection source, Collection remove)
  9. removeAll(final Collection c, final Object... array)

  10. HOME | Copyright © www.java2s.com 2016