-2
如何理解该程序的输出?当我执行下面的程序时,我看到下面的输出,但无法理解它是什么。距离collect()
输出:不理解collect的输出()
import java.util.List;
import java.util.Arrays;
import java.util.HashMap;
import java.util.stream.Collectors;
class example1 {
public static void main(String []args){
List <Integer> list = Arrays.asList(new Integer []{3,4,5,6,7,8,9});
HashMap<Integer, List<Integer>> map =
list.parallelStream().collect(Collectors.groupingByConcurrent(i->i%2 == 0?1:2)); /* what's problem here */
System.out.println(map.get(0));
}
}
输出
java: incompatible types: inference variable R has incompatible bounds equality constraints:
java.util.concurrent.ConcurrentMap<java.lang.Integer,java.util.List<java.lang. Integer>> upper bounds:
java.util.concurrent.ConcurrentHashMap<java.lang.Integer,java.util.List<java.lang.Integer>>,java.lang.Object
请出示一些努力。 –
如果在IDE中打开它,会发生什么?提示:这里是否适用HashMap? – jdv