@Test public void testIntersection() { Set<String> a = new HashSet<>(); a.add("foo"); a.add("bar"); a.add("baz"); a.add("qux"); Set<String> b = new HashSet<>(); b.add("bar"); b.add("baz"); Set<String> intersection = Sets.intersection(a, b); assertEquals(2, intersection.size()); assertTrue(intersection.contains("bar")); assertTrue(intersection.contains("baz")); }
public static <T> Set<T> intersection(Set<T> a, Set<T> b) { Set<T> intersection = new HashSet<>(a); intersection.retainAll(b); return intersection; }
Sets { public static <T> Set<T> intersection(Set<T> a, Set<T> b) { Set<T> intersection = new HashSet<>(a); intersection.retainAll(b); return intersection; } }
Sets { public static <T> Set<T> intersection(Set<T> a, Set<T> b) { Set<T> intersection = new HashSet<>(a); intersection.retainAll(b); return intersection; }  }
Sets { public static <T> Set<T> intersection(Set<T> a, Set<T> b) { Set<T> intersection = new HashSet<>(a); intersection.retainAll(b); return intersection; }  static Set<T> intersection(Set<T> a, Set<T> b); }
Sets { public static <T> Set<T> intersection(Set<T> a, Set<T> b) { Set<T> intersection = new HashSet<>(a); intersection.retainAll(b); return intersection; }  static Set<T> intersection(Set<T> a, Set<T> b);  }