Horje
find highest value in keyset java Code Example
find the greatest number in hashmap
public class NewClass4 {
    public static void main(String[] args)
    {
        HashMap<Integer,Integer>map=new HashMap<Integer, Integer>();
        map.put(1, 50);
        map.put(2, 60);
        map.put(3, 30);
        map.put(4, 60);
        map.put(5, 60);
        int maxValueInMap=(Collections.max(map.values()));  // This will return max value in the Hashmap
        for (Entry<Integer, Integer> entry : map.entrySet()) {  // Itrate through hashmap
            if (entry.getValue()==maxValueInMap) {
                System.out.println(entry.getKey());     // Print the key with max value
            }
        }

    }
}
find highest value in keyset java
countMap.entrySet().stream().max((entry1, entry2) -> entry1.getValue() > entry2.getValue() ? 1 : -1).get().getKey();




Java

Related
java remove map Code Example java remove map Code Example
public static void main vs static public void main Code Example public static void main vs static public void main Code Example
add a value to a list java in java hashmap Code Example add a value to a list java in java hashmap Code Example
do you need java installed for kafka Code Example do you need java installed for kafka Code Example
how can i convert an int to string java Code Example how can i convert an int to string java Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9