Java Program to Find Maximum Occurring Character in a String
![Image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzMx5AVvyEdYq-KO-5Q16aQpijeoZywt27fIlkZuC0hq5ZRfXmzpCbj42gyU0vUfaFJqvQbbtcvEl1YTBTwJWiCB5DoTzsw-hrZrOYXt6b-iF22Bm6d5cIKRRYvj7m9S8cSXlKxBZDIzoKvW8K2RmPX0zJFsczMnEJGy7hzQgHLWsk9lwZMuBLMxIhxUPt/s16000/java-icon.png)
In this section, we will show you how to find m aximum occurring character in a string . 1. Using For loop and Map 2. Using For loop 3. Using Java 9 chars() method 4. Using Java 8 Streams Example 1. Using For loop and Map Note: We may have more than one character with the same maximum occurence . This program will print all the character with maximum occurence . import java.util.Collections ; import java.util.HashMap ; import java.util.Map ; public class Main { public static void main ( String [] args) { String string = "java awesome dude" ; char chars [] = string .toCharArray(); Map < Character , Integer > occurrences = new HashMap<>(); for ( Character character : chars ) { Integer oldCount = occurrences .get( character ); if ( oldCount == null ) { oldCount = 0 ; } occurrences .put( character , oldCount + 1 ); } int maxValue =( Collections