public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
System.out.println("请输入一个字符串");
//创建一个布尔数组,用于标记
boolean[] bs = new boolean[s.length()];
for(int i = 0; i < bs.length; i++){
if(bs[i]){
continue;//如果是true跳过,下面的代码不执行
}
//代码如果能够执行到这一行,代表i位置的字符还没有被标记
//获取i位置的字符
char c = s.charAt(i);
int count = 0;
for(int j = 0; j<s.length(); j++){
if(c == s.charAt(j)){
count++;
bs[j]=true;
}
}
System.out.println(c + "出现的次数" + count);
}
}
}