Description: package defalt
public class Hellow {
public static void main(String args[])
{String str1="Hello,it is Tom speaking,who is that?"
String str2="is"
System.out.println(countStr(str1,str2))
}
public static int countStr(String str1,String str2){
int num=0
int indexFrom=0
indexFrom=str1.indexOf(str2,indexFrom)
while(indexFrom!=-1){
num++
indexFrom+=str2.length()
indexFrom=str1.indexOf(str2,indexFrom)
}
return num
}
}
To Search:
File list (Check if you may need any files):
Demo6\.classpath
.....\.project
.....\.settings\org.eclipse.jdt.core.prefs
.....\bin\cn\ICompare.class
.....\...\..\NoStudentException.class
.....\...\..\Student.class
.....\...\..\Worker.class
.....\src\cn\ICompare.java
.....\...\..\NoStudentException.java
.....\...\..\Student.java
.....\...\..\Worker.java
.....\bin\cn
.....\src\cn
.....\.settings
.....\bin
.....\src
Demo6