List of utility methods to do ArrayList Intersect
ArrayList | Intersect(ArrayList 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); |
ArrayList | intersection(ArrayList 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; |
ArrayList | intersection(ArrayList 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) { ... |