Java List Intersect intersection(List list1, List list2)

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

Description

intersection

License

Open Source License

Declaration

public static <E> List<E> intersection(List<E> list1, List<E> list2) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.*;

public class Main {
    public static <E> List<E> intersection(List<E> list1, List<E> list2) {
        if (list1 == null || list2 == null)
            throw new NullPointerException("Not initizalized lists");
        List<E> intersection = new LinkedList<E>();
        E item;//from   w w w.j a va2  s .c  o  m
        ListIterator<E> iter = list1.listIterator();
        while (iter.hasNext()) {
            item = iter.next();
            if (list2.contains(item)) {
                intersection.add(item);
            }
        }
        return intersection;
    }
}

Related

  1. intersectDate(List oDate, List tDate)
  2. intersection(final List list1, final List list2)
  3. intersection(final List list1, final List list2)
  4. intersection(final List list1, final List list2)
  5. intersection(List> sets)
  6. intersection(List list1, List list2)
  7. Intersection(List a, List b)
  8. intersection(List list1, List list2)
  9. intersection(List arrayOne, List arrayTwo)