Один
Код: Выделить всё
Map map = new HashMap();
List numList = map.entrySet().stream()
.sorted(Comparator.comparing(Map.Entry::getValue).reversed()) //this part
.map(Map.Entry::getKey)
.toList();
Код: Выделить всё
java: incompatible types: cannot infer type-variable(s) T,U
(argument mismatch; invalid method reference
method getValue in interface java.util.Map.Entry cannot be applied to given types
required: no arguments
found: java.lang.Object
reason: actual and formal argument lists differ in length)
Два
Код: Выделить всё
Map map = new HashMap();
List numList = map.entrySet().stream()
.sorted(Comparator.comparing(Map.Entry::getValue).reversed())
.map(Map.Entry::getKey)
.toList();
Код: Выделить всё
Map map = new HashMap();
List numList = map.entrySet().stream()
.sorted(Comparator.comparing(Map.Entry::getValue))
.map(Map.Entry::getKey)
.toList();
Подробнее здесь: https://stackoverflow.com/questions/797 ... ry-objects
Мобильная версия