-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