public class Count {
public static void main(String []args){
int ch=0;
int nu=0;
int blank=0;
int ot=0;
String st = JOptionPane.showInputDialog("请输入字符串");
for(int i=0;i<st.length();i++){
char n=st.charAt(i);
if(n>='0'&&n<='9')nu++;
else if((n>='a'&n<='z')||(n>='A'&n<='Z'))ch++;
else if(n==' ')blank++;
else ot++;
}
JOptionPane.showMessageDialog(null, "字母的个数为:"+ch+"\n数字的个数为:"+nu+"\n空格的个数为:"+blank+"\n其他符号的个数为:"+ot);
}