Write code to get the maximum occurring character in inputString
//package com.book2s; public class Main { public static void main(String[] argv) { String inputString = "book2s.com"; System.out.println(getMaximumOccurringCharacter(inputString)); }//from ww w .ja v a 2s. com /*** * getMaximumOcurringCharacter(final String inputString) * get the maximum occurring character in inputString * @param inputString * @return */ public static char getMaximumOccurringCharacter(final String inputString) { if (inputString != null && inputString.length() != 0) { final char[] inputStringArray = inputString.toCharArray(); int countChar[] = new int[59]; int maxOccurance = 0; int charToReturn = 0; int index = 0; for (char i : inputStringArray) { index = (int) i - 64; countChar[index] = (countChar[index]) + 1; if (maxOccurance < countChar[index]) { maxOccurance = countChar[index]; charToReturn = index + 64; } } return (char) charToReturn; } else { throw new NullPointerException(); } } }