I have made a Java prog which will accept a word and a sentence, and then prints the number of times the word occurs in the sentence...
Here is my code:
class check_number_word
{
void check(String w, String s)
{
int l=s.length(),n=0,d=0;
String s1="";
for(int j=1;j<l;j++)
{
s1=s.substring(d,j);
if(s1.equalsIgnoreCase(w))
{
d=j+2;
j=d+1;
n++;
}
}
System.out.println(n);
}
}
But, the program is not working? Any ideas why?