Java编程关于LOOP问题!

来源:百度知道 编辑:UC知道 时间:2024/07/07 10:42:03
菜鸟求助!
初学者,自己有琢磨了一下!
但是也不是很懂!
希望高手帮忙下面的编程
/**
* Count the number of occurrences of a particular word in a given string.
* For example, wordCount("The damsel then ate the dragon.", "the") returns 1.
* [Neither "The" nor "then" match "the", because capital letters are
* different from lower case letters and only whole words match.]
*
* @param fullString the string in which occurrences of word are to be counted
* @param targetWord the word whose occurrences are to be counted
* @return the number of times "word" occurs as a separate word
*
* NOTE: This method should make use of the StringTokenizer class.
*/
/*
* HINTS:
* A while loop is most appropriate for this method.
* (while loops are used when you do not know in advance how many times a loop will repeat)
*
* StringTokenizer is another class in the project. Open it and

Count the number of occurrences of a particular word in a given string.
//计算给出的字符串再 原有字符串位置?
* For example, wordCount("The damsel then ate the dragon.", "the") returns 1.
* [Neither "The" nor "then" match "the", because capital letters are
* different from lower case letters and only whole words match.]
*
* @param fullString the string in which occurrences of word are to be counted
* @param targetWord the word whose occurrences are to be counted
* @return the number of times "word" occurs as a separate word
*
* NOTE: This method should make use of the StringTokenizer class

英文水平有限大致意思。让你按要求写return 0;// 这段代码
要求大概是第二个参数 是第一个参数中有几个这样的词,要全词匹配, whole words match。 例如The damsel then ate the dragon 只有一个the retun 1
the damsel then ate the dragon return 2

/**
* Count the number of occurrences of a particular word in a given string.
* For