void () { Map<Integer, ? extends MyList2<? extends Number, ? extends CharSequence>> map = getList().stream().collect(Collectors.groupingBy(x -> x.length(), Collectors.toCollection(this::createMyList2))); System.out.println(map); }