public class Aa3Count {
public static void main(String[] args){
String st =
"A123 C_Ddf8*gX";
int numCapital =
0;
int numlowercaseletter =
0;
int numOther =
0;
for(
int i=
0; i<st.length(); i++){
char c = st.charAt(i);
if(
'a'<=c && c<=
'z'){
numlowercaseletter++;
}
else if(
'A'<=c && c<=
'Z'){
numCapital++;
}
else{
numOther++;
}
}
System.
out.println(
"大写字母有:"+numCapital+
" 小写字母有:"+numlowercaseletter+
" 非英文字母数有:"+numOther);
}
}
运行结果: 大写字母有:4 小写字母有:3 非英文字母数有:7