### Question:
Combinatorics { public static <T> Set<Set<T>> combinations(Set<T> elements, int subsetSize) { return combinationsStream(elements, subsetSize).collect(Collectors.toSet()); }  static Collection<List<T>> permutations(Collection<T> elements); static Set<Set<T>> combinations(Set<T> elements, int subsetSize); static Stream<Set<T>> combinationsStream(Set<T> elements, int subsetSize); static Iterator<T[]> combinationsIterator(final T[] elements, final int subsetSize);  }### Answer:
@Test public void testCombinations() { logger.info("combinations"); Set<Set<String>> expResult = new HashSet<>(); expResult.add(new HashSet<>(Arrays.asList("a","b"))); expResult.add(new HashSet<>(Arrays.asList("a","c"))); expResult.add(new HashSet<>(Arrays.asList("b","c"))); Set<Set<String>> result = Combinatorics.combinations(new HashSet<>(Arrays.asList("a","b","c","a")), 2); assertEquals(expResult, result); }