Stack Overflow Asked by Marika on December 16, 2021
How to find the five?
HashMap<Integer, Integer> hmap = new HashMap<Integer, Integer>();
hmap.put(98, 3);
hmap.put(-120, 2);
hmap.put(12, 5);
hmap.put(344, 1);
hmap.put(-220, 1);
I tried this but it doesn’t like my hmap.
System.out.println(Collections.max(hmap));
You can get the value of map using hmap.values()
then use Collections.max
to get max value
Collections.max(hmap.values());
Answered by Eklavya on December 16, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP