Java Utililty Methods ArrayList Intersect

List of utility methods to do ArrayList Intersect

Description

The list of methods to do ArrayList Intersect are organized into topic(s).

Method

ArrayListIntersect(ArrayList list1, ArrayList list2)
Finds the intersection between two lists of String objects.
if (list1.size() == 0)
    return list2;
Set intersection = new HashSet(list1);
intersection.retainAll(new HashSet(list2));
return new ArrayList(intersection);
ArrayListintersection(ArrayList List1, ArrayList List2)
Returns the intersection of two lists passed to it.
ArrayList<Integer> intersection = new ArrayList<Integer>();
if (List1 != null && List2 != null)
    for (int i : List1)
        if (List2.contains(i))
            intersection.add(i);
return intersection;
ArrayListintersection(ArrayList list1, ArrayList list2)
intersection
ArrayList<String> result = new ArrayList<String>();
int i1 = 0;
int i2 = 0;
while (i1 < list1.size() && i2 < list2.size()) {
    String s1 = list1.get(i1);
    String s2 = list2.get(i2);
    int num = s1.compareTo(s2);
    if (num == 0) {
...