//Get top 3 entries of a map, compared by value
Map<String,Integer> mapWithTop3Entries = hm.entrySet().stream().sorted(Map.Entry.<String, Integer>comparingByValue().reversed()).limit(3).collect(Collectors.toMap(Map.Entry::getKey,Map.Entry::getValue));