mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-02 03:07:47 +07:00
20 lines
586 B
Java
20 lines
586 B
Java
// "Replace Stream API chain with loop" "true"
|
|
|
|
import java.util.*;
|
|
import java.util.function.Function;
|
|
import java.util.stream.Collectors;
|
|
|
|
public class Main {
|
|
public static void test(List<String> strings) {
|
|
Map<Integer, Map<Character, Set<String>>> map = new HashMap<>();
|
|
for (String s : strings) {
|
|
map.computeIfAbsent(s.length(), key -> new HashMap<>()).computeIfAbsent(s.charAt(0), k -> new HashSet<>()).add(s);
|
|
}
|
|
System.out.println(map);
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
test(Arrays.asList("a", "bbb", "cccc", "dddd"));
|
|
}
|
|
}
|