import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String line = scanner.nextLine(); Map<Character, Integer> map = new LinkedHashMap<Character, Integer>(); //write your code here...... for(int i=0;i<line.length();i++) { char c=line.charAt(i); if(c>='A'&&c<='Z'||c>='a'&&c<='z') { if(map.containsKey(c)==true){//如果此映射包含指定键的映射,则返回true map.put(c,map.get(c)+1);//get()返回到指定键所映射的值,或null如果此映射包含该键的映射。 }else{ map.put(c,1); } } } Set<Map.Entry<Character, Integer>> entrys = map.entrySet(); for (Map.Entry<Character, Integer> entry : entrys) { System.out.println(entry.getKey() + ":" + entry.getValue()); } } }