mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-03 19:58:23 +07:00
20 lines
521 B
Java
20 lines
521 B
Java
// "Collapse loop with stream 'collect()'" "true-preview"
|
|
package com.google.common.collect;
|
|
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.IntStream;
|
|
|
|
class Maps {
|
|
public static <K, V> HashMap<K, V> newHashMap() {
|
|
return new HashMap<K, V>();
|
|
}
|
|
}
|
|
|
|
public class Test {
|
|
public void test() {
|
|
Map<String, Integer> map = IntStream.range(0, 10).filter(i -> i % 2 == 0).boxed().collect(Collectors.toMap(String::valueOf, i -> i, (a, b) -> b));
|
|
System.out.println(map);
|
|
}
|
|
}
|