Код: Выделить всё
int size = ...
var a = new ArrayList();
for (Map.Entry e : myHashMap) {
a.add( String.format("%s %.3f", e.getKey(), 100.0 * e.getValue() / size));
}
Код: Выделить всё
int size = ...
var a = myHashMap.entrySet()
.stream()
.sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
.map(Map.Entry::getValue)
.toList();
Подробнее здесь: https://stackoverflow.com/questions/791 ... sing-strin
Мобильная версия