import java.util.TreeMap;
public class Test2 {
public static void main(String[] args) {
String str="aabbbbaacccccccccc";
char[] arr=str.toCharArray();
TreeMap<Character,Integer> tm=new TreeMap<>();
for(char c:arr)
{
tm.put(c, !tm.containsKey(c)?1:tm.get(c)+1);
}
for(Character c:tm.keySet())
{
System.out.println(c+"="+tm.get(c));
}
}
}
|
|