// "Replace with collect" "true" import java.util.*; public class Main { private Map> test(String... list) { Map> map = new HashMap<>(); for(String s : list) { map.computeIfAbsent(s.length(), k -> new ArrayList<>()).add(s); } return map; } }