import java.util.StringTokenizer;
public class Test {
public static int tongji(String input) {
int count = 0;
StringTokenizer tokenizer = new StringTokenizer(input);
while (tokenizer.hasMoreElements()) {
String element = (String) tokenizer.nextElement();
if ("the".equalsIgnoreCase(element))
count++;
}
return count;
}
public static void main(String[] args) {
System.out.println(tongji("The great wall is a the most wonderful building"));
}
}
温馨提示:答案为网友推荐,仅供参考