黑马程序员技术交流社区
标题: 计算字符串中子串出现的次数 [打印本页]
作者: pathnet 时间: 2015-7-14 00:03
标题: 计算字符串中子串出现的次数
public static void main(String[] args){
String str = "I come from County DingYuan Province AnHui.";
char[] ch = str.toCharArray();
int count = 0;
for(int i=0;i<ch.length;i++){
if(ch==' ')
count++;
}
count++;
System.out.println("共有"+count+"个字串");
}
| 欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) |
黑马程序员IT技术论坛 X3.2 |