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);
}
Above code builds and runs perfectly but it shouldn't. Comparator.comparing takes a function reference and only those methods which takes one argument and returns one argument can be mapped on this. But in above code getValue is mapped and works fine but it doesn't take any parameter. Code should give build issue but doesn't. Is there any issue with my concept?