Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class Main {
    public static <K, V extends Comparable> K getKeyOfMaxValue(ConcurrentHashMap<K, V> map) {
        Map.Entry<K, V> entry = map.reduceEntries(1000, (oldEntry, newEntry) -> {
            if (oldEntry.getValue().compareTo(newEntry.getValue()) > 0)
                return oldEntry;
            else
                return newEntry;
        });
        return entry.getKey();
    }
}