话不多说,直接上代码...........

 

public static void main(String[] args) {

  String str="I'm go to swimming";
  Set<String> set=new HashSet<>();
  for (int i = 0; i < str.length(); i++) {
    String s = str.substring(i, i+1);
    set.add(s);
  }

  Iterator<String> it = set.iterator();
  while(it.hasNext()){
    String sr=(String)it.next();
  int k=0;
  for (int j = 0; j < str.length(); j++) {
    if(sr.equals(str.substring(j,j+1))){
    k++;
    }
   }
  System.out.println(sr+"有"+k+"个");
  }

}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-26
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-29
  • 2021-07-14
  • 2022-12-23
  • 2022-12-23
  • 2021-09-02
  • 2022-02-20
相关资源
相似解决方案