// "Replace Stream API chain with loop" "true" import java.util.*; import java.util.stream.Collectors; public class Main { static class MyList extends ArrayList {} public List getList() { return Collections.emptyList(); } public MyList createList() { return new MyList<>(); } private void collect() { Map> result = new HashMap<>(); for (CharSequence x : getList()) { result.computeIfAbsent(x.length(), k -> createList()).add(x); } Map> map = result; System.out.println(map); }