package action;
import java.util.Arrays;
import java.util.TreeSet;
public class test {
/**
* @param args
*/
public static void main(String[] args) {
String strs = "ZZZ BBB AAA OOO ZZZ AAA ZZZ BBB AAA ZZZ AAA VVV OOO CCC DDD CCC CCC KKK BBB AAA ZZZ AAA CCC KKK";
String[] word = strs.split(" ");
TreeSet set = new TreeSet();//去重复使用TreeSet
//排序
Arrays.sort(word);
//计算出现个数
for (int i = 0; i < word.length; i++) {
int count = 0;
for (int j = 0; j < word.length; j++) {
if (word[i].equals(word[j])) {
count += 1;
}
}
set.add(word[i]+":"+count);
}
//去重复
for(String s:set){
System.out.println(s);
}
}
}