Comment trouver le caractère maximal dans une chaîne donnée? Utilisation de Hashmap Java

private static void maxOccuringCharacterInString(String s){

        Map<Character,Integer> map = new HashMap<>();
        for(int i=0; i<s.length(); i++){
            if(!map.containsKey(s.charAt(i))){
                map.put(s.charAt(i),1);
            }
            else{
                map.put(s.charAt(i),map.get(s.charAt(i))+1);  // means there is an existing char
                // in string which is already present in map.
            }
        }
        int maxCount = 0;
        char maxChar = 0;
        for(Map.Entry<Character,Integer> m : map.entrySet()) {
            if (m.getValue() > maxCount) {
                maxCount = m.getValue();
                maxChar = m.getKey();
            }
        }
            System.out.println(maxChar+" : "+maxCount);
        }
Techie Ash