I wrote following method to find the keys mapped to the highest values and trying to convert to java Stream
s. Can you please help?
private List<Integer> testStreamMap(Map<Integer, Long> mapGroup)
{
List<Integer> listMax = new ArrayList<Integer>();
Long frequency = 0L;
for (Integer key : mapGroup.keySet()) {
Long occurrence = mapGroup.get(key);
if (occurrence > frequency) {
listMax.clear();
listMax.add(key);
frequency = occurrence;
} else if (occurrence == frequency) {
listMax.add(key);
}
}
return listMax;
}