Skip to content

Highest Value In Map

Featured Replies

What's the best way to find the highest value in a HashMap / Map

 

Example. 

Map<String, Integer> _ILoveCookiesButMySisterAteAllOfThemIn1NightThatBitch = new HashMap<>();

 

What would u use to get the highest value?

Collection.max ? 

 

 

Yes Collections.max(_ILoveCookiesButMySisterAteAllOfThemIn1NightThatBitch.entrySet(), Map.Entry.comparingByValue()).getKey();

Edited by melron

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.