Java List Intersect intersection(List listOne, List listTwo)

Here you can find the source of intersection(List listOne, List listTwo)

Description

intersection

License

Apache License

Declaration

public static <T> List<T> intersection(List<T> listOne, List<T> listTwo) 

Method Source Code


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

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static <T> List<T> intersection(List<T> listOne, List<T> listTwo) {
        ArrayList<T> onlyInOne = new ArrayList<T>(listOne);
        onlyInOne.removeAll(listTwo);/*from ww w.j  a  v  a2 s . c om*/

        ArrayList<T> inBoth = new ArrayList<T>(listOne);
        inBoth.removeAll(onlyInOne);

        return inBoth;
    }
}

Related

  1. intersection(List list1, List list2)
  2. intersection(List list1, List list2)
  3. Intersection(List a, List b)
  4. intersection(List list1, List list2)
  5. intersection(List arrayOne, List arrayTwo)
  6. intersection(List set1, List set2)
  7. intersection_type(List list1, List list2)
  8. intersectionInplace(List> sets)
  9. intersectList(List list1, List list2)