public class Tjizifugeshu {
public static void main(String[] args) {
// TODO Auto-generated method stub
int daxie=0;
int xiaoxie=0;
int shuzi=0;
System.out.println("请输入字符串");
Scanner scanner=new Scanner(System.in);
String a=scanner.nextLine();
for(int i=0;i<a.length();i++) {
char b=a.charAt(i);
if(b>='A'&& b<='Z') {
daxie++;
}else if(b>='a'&& b<='z'){
xiaoxie++;
}else if(b>='0'&& b<='9');
shuzi++;
}
System.out.println("大写字母的个数为"+daxie+"个"+"\n小写字母的个数为"+xiaoxie+"个"+"\n数字的个数为"+shuzi+"个");
}
}
请输入字符串
JGUGDkjkcjei9893
大写字母的个数为5个
小写字母的个数为7个
数字的个数为16个
else if(b>='0'&& b<='9');
这里分号删掉