public class StringDemo {
public static void main(String[] args){
String str = "aaaabbbbccccdddda";
//分别为四个字母定义计数器;
int count1 = 0;int count2 = 0;
int count3 = 0;
int count4 = 0;
char[] c = str.toCharArray(); //将字符串转换成字符数组;
for(int i =0;i<c.length;i++){
if(c[i]=='a'){
count1++;
}else if(c[i]=='b'){
count2++;
}else if(c[i]=='c'){
count3++;
}else if(c[i]=='d'){
count4++;
}
}
System.out.println("a"+count1+"b"+count2+"c"+count3+"d"+count4);
}
}