cloudLi

package com.test;

public class zifuchuanbianli {
public static void main(String[] args) {
String s ="ABCDEabcdef123456!@#$%%^";
int big = 0;
int small = 0;
int num = 0;
int other = 0;
for(int i=0;i<s.length();i++) {
//System.out.println(s.charAt(i));
char c = s.charAt(i); //通过索引拿取每一个字符
//判断是否在此范围之内
if(c >= \'A\' && c <= \'Z\') {
big++; //如果满足大写,计数器递增
}else if(c >= \'a\' && c <= \'z\'){
small++;
}else if(c >= \'0\' && c <= \'9\') {
num++;
}else {
other++;
}
}
System.out.println("大写字母"+big);
System.out.println("小写字母"+small);
System.out.println("数字"+num);
System.out.println("其他"+other);
}
}

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-27
  • 2021-07-10
  • 2022-12-23
  • 2022-02-20
猜你喜欢
  • 2022-02-03
  • 2022-12-23
  • 2021-05-11
  • 2021-06-16
  • 2021-05-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案