void () { Object map1 = Stream.of(1, 2, 3, 4).map(String::valueOf) .collect(Collectors.groupingBy(String::length, TreeMap::new, Collectors.toSet())); TreeMap<Integer, Set<String>> map2 = Stream.of(1, 2, 3, 4).map(String::valueOf).collect(Collectors .groupingBy(String::length, TreeMap::new, Collectors.toSet())); NavigableMap<Integer, Set<String>> map3 = Stream.of(1, 2, 3, 4).map(String::valueOf).collect(Collectors .groupingBy(String::length, TreeMap::new, Collectors.toSet())); SortedMap<Integer, Set<String>> map4 = Stream.of(1, 2, 3, 4).map(String::valueOf).collect(Collectors .groupingBy(String::length, TreeMap::new, Collectors.toSet())); Cloneable map5 = Stream.of(1, 2, 3, 4).map(String::valueOf) .collect(Collectors.groupingBy(String::length, TreeMap::new, Collectors.toSet())); }