package timu;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class TestTime {
public static void main(String[] args){
String arr = "ABDDSSKJAJUYBCcccdbtaekaekw";
Map
char[] array = arr.toCharArray();
for(int i = 0; i < array.length; i++){
if(Character.isUpperCase(array[i])){
if(map.containsKey(array[i])){
map.put(array[i], map.get(array[i]) + 1);
}else{
map.put(array[i], 1);
}
}
}
Set set = map.keySet();
Iterator it = set.iterator();
while(it.hasNext()){
Character c = (Character) it.next();
System.out.println(c +":" + map.get(c) );
}
}
}
使用Map