public class Practice
{
private static void readWord ( String input, String word, int offset, int count )
{
offset = input.indexOf (word, offset);
if (offset != -1)
{
System.out.println (word + " 在第 " + offset + " 个位置出现过.");
readWord (input, word, ++offset, ++count);
}
else
{
System.out.println (word + " 总共出现了:" + count + " 次.");
}
}
public static void main ( String[] args )
{
String input = "Look buddy, U got work hard and put yourself to the java, once U learned the heart of java, I can guarantee that U win.";
String word = "java";
readWord (input, word, 0, 0);
}
}