这个java程序在jcreator里运行,不抱错,但没有结果,为什么啊?
publicclassTestString{publicstaticvoidmain(String[]args){Strings="AssBbb*&&iwngeWoWO"...
public class TestString {
public static void main(String[] args) {
String s = "AssBbb*&&iwngeWoWO";
String s1 = "sunjavahpjavakjavahjavahahajavajavagoodjava";
String sToFind = "java";
int index = -1;
int count = 0;
while((index = s1.indexOf(sToFind)) != -1);{
s1 = s1.substring(index + sToFind.length());
count++;
}
System.out.println(count);
}
}
请高手指点一二。 展开
public static void main(String[] args) {
String s = "AssBbb*&&iwngeWoWO";
String s1 = "sunjavahpjavakjavahjavahahajavajavagoodjava";
String sToFind = "java";
int index = -1;
int count = 0;
while((index = s1.indexOf(sToFind)) != -1);{
s1 = s1.substring(index + sToFind.length());
count++;
}
System.out.println(count);
}
}
请高手指点一二。 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询