void (String[] args) { List<String> input = Arrays.asList("a", "bbb", "cc", "ddd", " x", "ee"); Map<Integer, String> map3 = input.stream().collect(Collectors.toConcurrentMap(String::length, Function.identity(), BinaryOperator.maxBy(String::compareTo))); System.out.println(map3); }