Java List Difference difference(final List list1, final List list2)

Here you can find the source of difference(final List list1, final List list2)

Description

difference

License

Apache License

Declaration

public static <T> List<T> difference(final List<? extends T> list1, final List<? extends T> list2) 

Method Source Code


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

import java.util.ArrayList;

import java.util.Iterator;

import java.util.List;

public class Main {

    public static <T> List<T> difference(final List<? extends T> list1, final List<? extends T> list2) {
        final List<T> result = new ArrayList<T>(list1);
        final Iterator<? extends T> iterator = list2.iterator();

        while (iterator.hasNext()) {
            result.remove(iterator.next());
        }//  ww  w . j ava  2  s  . co m

        return result;
    }
}

Related

  1. diff(List ls, List ls2)
  2. diff(List doublesA, List doublesB)
  3. diffAsSet(Collection list1, Collection list2)
  4. difference(final List minuend, final List subtrahend)
  5. difference(final String[] list1, final String[] list2)
  6. difference(List firstList, List secondList)
  7. difference(List lst1, List lst2)
  8. difference(List set1, List set2)