import?java.util.TreeMap;
/**
*?從鍵盤輸入16位長整數,編程統計每個數字出現的個數 *?@author?young * */public?class?CharMapDemo?{
public?static?TreeMap<Character,?Integer>?Pross(String?str)?{
char[]?charArray?=?str.toCharArray();
TreeMap<Character,?Integer>?tm?=?new?TreeMap<Character,?Integer>();
for?(int?x?=?0;?x?<?charArray.length;?x++)?{
if?(!tm.containsKey(charArray[x]))?{
tm.put(charArray[x],?1);
}?else?{
int?count?=?tm.get(charArray[x])?+?1;
tm.put(charArray[x],?count);
}
}
return?tm;
}
public?static?void?main(String[]?args)?{
Scanner?sc?=?new?Scanner(System.in);
System.out.println("請輸入壹個長整數:");
int?temp?=?sc.nextInt();
String?str?=?String.valueOf(temp);
TreeMap<Character,?Integer>?tm?=?Pross(str);
System.out.println(tm);
}
}