我对java8完全是个新手,我不太清楚该怎么做。我在Java7中有一个映射<String, List<value>>,我只需要在键上使用for循环,并将列表收集到一个列表中。map( // get the value in the list)但是,在这种情况下,我无法从值所属的hashmap中知道键。在
手头的任务是将集合的每个元素映射到0。所以我想把这个List转换成一个Set,然后映射到0。map = Arrays.stream(elements) .collect(Collectors.toMap(x -> x, x -> 0));
但是当我尝试这个的时候DeleteElementsByOccurence.java:18) <-- Refers to the Collectors.toMap li