怎样判断字符串中有几个数字和标点符号 怎样判断字符串中有几个数字和标点符号 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 String包好像有个stoken(不记得怎么拼了,大致如此)方法可以分离和统计特殊符号 //输入字符串中字符中字母,数字和其他字符数目。class e2{ public static void main(String args[]) throws java.io.IOException{ int count_char=0; int count_number=0; int count_other=0; String s=" "; char c=' '; System.out.print("Please input the String numbers:"); c=(char) System.in.read(); //就是这行,怎么输入字符串?? for(int i=0;i<s.length();i++){ //从字符串中逐个获取字符 if(c>='a'&&c<='z'||c>='A'&&c<='Z') count_char++; //统计字母个数 else if(c>='0'&&c<='9') count_number++; //统计数字个数 else count_other++; } System.out.println("count_char="+count_char); System.out.println("count_number"+count_number); System.out.println("count_other"+count_other); }} 左右2个文本域,怎么实现把左边的内容移入右边的 请教个算法问题 小弟想走J2EE的道路,请高人引路! 这个方法为什么会提示返回类型出错 大家来看下我的程序为什么会出错的-_- 关于倒计时 怎麼樣用java把一個數用01表示出來 以下代码打星号处编译错误,请帮忙看看 flc +java? 大家都用RMI做一些什么事情?大家畅所欲言,来者有分。 ConnectionFactory实例化问题 请教两个问题
public static void main(String args[])
throws java.io.IOException{
int count_char=0;
int count_number=0;
int count_other=0;
String s=" ";
char c=' ';
System.out.print("Please input the String numbers:");
c=(char) System.in.read(); //就是这行,怎么输入字符串?? for(int i=0;i<s.length();i++){ //从字符串中逐个获取字符
if(c>='a'&&c<='z'||c>='A'&&c<='Z') count_char++; //统计字母个数
else if(c>='0'&&c<='9') count_number++; //统计数字个数
else count_other++;
}
System.out.println("count_char="+count_char);
System.out.println("count_number"+count_number);
System.out.println("count_other"+count_other);
}
}