public static void main(String o[]) {
Map<String, Integer> map = new HashMap<String, Integer>();
map.put("a", 1);
map.entrySet().stream().sorted(Comparator.comparing(Entry::getValue)).forEach(System.out::println);
}
Run Code Online (Sandbox Code Playgroud)
上面的代码构建和运行完美但不应该.Comparator.comparing采用函数引用,只有那些接受一个参数并返回一个参数的方法才能映射到此.但是在上面的代码中,getValue被映射并且工作正常但它不带任何参数.代码应该给出构建问题,但不是.我的概念有什么问题吗?