import java.io.*;
public class position
{ public static void main(String args[]) throws IOException
{ InputStreamReader read = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(read);
System.out.println("Enter a sentence");
String a=br.readLine();
System.out.println("Enter word to be searched for");
String word = br.readLine();
int count=0;
int pos=-1;
pos = a.indexOf(word);
while(pos>=0)
{ count++;
pos = pos + word.length();
pos = a.indexOf(word,pos);
}
System.out.println("Number of times word occurs " +count);
System.out.println(pos);
}
}
Tuesday, March 23, 2010
Count Number Of Times Word Occurs
Subscribe to:
Post Comments (Atom)
The post is written in very a good manner and it contains many useful information for me. word counter tool
ReplyDeleteHow to make money from slots: 7 Tips To Make Money Playing Slots
ReplyDeleteMost casino players know หารายได้เสริม the basics of 온카지노 casino slots, but they have found a way to make money 바카라 without risking your real money. You can get