本题目要求读入一个字符串,统计字符串中每个字符出现的次数,输出现次数最多(输入的数据中,出现次数最多的字符唯一)的字符以及次数。
在这里给出一组输入。例如:
import java.util.Scanner;
import java.util.*;
public class Day4 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
HashMap ma=new HashMap<>();
String str=sc.nextLine();
int max=0;
char chmax=' ';
for(int i=0;imax){ //如果当前key对应的value值大于最大值,更新max和chmax
max=ma.get(ch);
chmax=ch;
}
}
System.out.print(chmax+","+max);
}
}



