Print max occurring character in a String
Primitives over wrapper classes

public static Character findMaxOChar(String text) { ... }


It's usually recommended to prefer the primitive type over its wrapper class, unless you have a clear intention to return null values for indicating the absence of a value.

Interfaces over implementations

HashMap&lt;Character, Integer&gt; map = new HashMap&lt;Character, Integer&gt;();


Using the Map interface over the HashMap implementation is often recommended, as subsequent usage of the object only needs to know it's a Map. Since Java 7, you can rely on type inference for generic object creation to eliminate the redundant type specification on the right, i.e.:

Map&lt;Character, Integer&gt; map = new HashMap&lt;&gt;();


Java 8 stream-based processing

Assuming you are on Java 8 and eager to learn about its new stream-based processing, this is a good candidate for adopting this approach. :) For starters, you need to understand:


String.chars() can give you an IntStream of the string's characters, as long as we're talking about Western-based encoding.
A Collector that lets you apply some processing on a Stream to return some form of results, e.g. a Map in your case. Converting an IntStream to Stream&lt;Integer&gt; by calling IntStream.boxed().


Building the Map can be just:

Map&lt;Character, Long&gt; map = text.chars()
                                .boxed()
                                .collect(Collectors.groupingBy(
                                            i -&gt; Character.valueOf((char) i.intValue()),
                                            Collectors.counting()));


Here, we are groupingBy mapping the Integer values into Characters, and counting the number of occurrences.

Following the same idea,  you can call Map.entrySet().stream(), i.e. to stream on map's entries, to:


Group by the entries' values now, into a TreeMap, by mapping the entries' keys into a List,
Get the TreeMap's last entry, and from that entry's value, find any value to return as the result.