mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-01 18:58:31 +07:00
22 lines
580 B
Java
22 lines
580 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, Set<String>> map = new HashMap<>();
|
|
for (String string : strings) {
|
|
if (string != null) {
|
|
map.computeIfAbsent(string.length(), k -> new HashSet<>()).add(string);
|
|
}
|
|
}
|
|
System.out.println(map);
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
test(Arrays.asList("a", "bbb", "cccc", "dddd"));
|
|
}
|
|
}
|