import java.util.HashMap;
import java.util.Map;public class number_of_character {
public static void main(String[] args) { // TODO Auto-generated method stub String s = "asdasdugahjjaiosdhgbh"; Map <Character, Integer> map = new <Character, Integer> HashMap(); int len = s.length(); for(int i=0; i<s.length();i++) { Character k = s.charAt(i); map.put(k, (map.get(k) == null ? 1: map.get(k) + 1)); } System.out.println(map); char key = 0; int min=-1; for (Map.Entry<Character, Integer> entry : map.entrySet()) { if(min<entry.getValue()) { min=entry.getValue(); key=entry.getKey(); } } System.out.println("Key = " + key + ", Value = " +min); }
}