Java Program to Find Maximum Occurring Word 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 word in a string . 1. Using For loop and Map 2. Using For loop 3. Using Java 8 Streams Example 1. Using For loop and Map Note: We may have more than one key with the same maximum value. This program will print all the keys with maximum value. import java.util.Collections ; import java.util.HashMap ; import java.util.Map ; public class Main { public static void main ( String [] args) { String string = "Java Python Go C# Java Python Java Go C Go" ; String words [] = string .split( " " ); Map < String , Integer > occurrences = new HashMap<>(); for ( String word : words ) { Integer oldCount = occurrences .get( word ); if ( oldCount == null ) { oldCount = 0 ; } occurrences .put( word , oldCount + 1 ); } int maxValue =( Collections . max ( occurrences .values())); fo