public class test {
public static void main(String[] args) {
//è¦ç»è®¡çå符串
String s = "n290ur #@%8 ujj29rj10xk9" ;
//大ååæ¯ä¸ªæ°
int a = 0;
//å°ååæ¯ä¸ªæ°
int b = 0 ;
//æ°å个æ°
int c = 0;
//ç©ºæ ¼ä¸ªæ°
int d = 0;
//å
¶ä»å符个æ°
int e = 0;
String s1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
String s2 = "abcdefghijklmnopqrstuvwxyz";
String s3 = "0123456789";
String s4 = " ";
for(int i= 0;i < s.length();i++){
char str = s.charAt(i);
if(s1.indexOf(str)!=-1){
a++;
}else if(s2.indexOf(str)!=-1){
b++;
}else if(s3.indexOf(str)!=-1){
c++;
}else if(s4.indexOf(str)!=-1){
d++;
}else{
e++;
}
}
System.out.println("大ååæ¯ä¸ªæ°ï¼"+a);
System.out.println("å°ååæ¯ä¸ªæ°ï¼"+b);
System.out.println("æ°å个æ°ï¼"+c);
System.out.println("ç©ºæ ¼ä¸ªæ°ï¼"+d);
System.out.println("å
¶ä»å符个æ°ï¼"+e);
}
}
温馨提示:答案为网友推荐,仅供参考