I have a method reference question in Java.
I want to transform this lambda code:
Collections.sort(trends, (map1, map2) -> (int) ((long) map2.get("pageview") - (long) map1.get("pageview")));
How to use Integer::compareTo?
Integer::compareTo
In order to user method reference "Integer::compareTo" try this:
Collections.sort(trends, Comparator.comparing( map -> -map.get("pageview").intValue(), Integer::compareTo));
2.1m questions
2.1m answers
60 comments
57.0k users