I have a string and i created a map which schows occurrences of characters:
String: "aaa bbbb ccccccccccc ddddd eeee"
map: {a=3, b=4, c=11, d=5, e=4}
And i want to display only c, also output:
c
(because it occurres most of the times).
>Solution :
You can find the max key using streams like this:
Character maxKey = map.entrySet().stream()
.max(Map.Entry.comparingByValue())
.get().getKey();