My question is word count duplicated in Java count duplicates word it count character only enter code here.
I am use core Java program only
public static void getCount(String name) {
Map<Character, Integer> names = new HashMap<Character, Integer>();
for(int i = 0; i < name.length(); i++) {
char c = name.charAt(i);
Integer count = names.get(c);
System.out.println(names.get(c));
System.out.println("the count"+count);
if (count == null) {
count = 0;
}
names.put(c, count + 1);
System.out.println("111111111111");}`
Set<Character> a = names.keySet();
for (Character t : a) {
System.out.println(t + " Ocurred " + names.get(t) + " times");
}
i think this may help you
or (I think this will have a better performance)