public static void main(String[] args){
  int abcCount = 0;
  int numCount = 0;
  int SpaceCount = 0;
  int otherCount = 0;
  Scanner sc = new Scanner(System.in);
  String str = sc.nextLine();
  char[] ch = str.toCharArray();
  for(int i = 0; i < ch.length;i++){
  if(Character.isLetter(ch[i])){abcCount++;}
  else if(Character.isDigit(ch[i])){numCount++;}
  else if(Character.isSpaceChar(ch[i])){SpaceCount++;}
  else{otherCount++;}
 }System.out.println("字母数是:"+ abcCount);
 System.out.println("数字数是:"+ numCount);
 System.out.println("空格数是:" + SpaceCount);
 System.out.println("其他的是:" + otherCount);
 

  }

}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-12
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-04
  • 2021-12-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
相关资源
相似解决方案