【发布时间】:2014-11-04 21:38:39
【问题描述】:
我正在尝试编写一个方法,该方法从“words”参数中返回至少具有“min”但不超过“max c”字符的单词数。
public static int countWords(String words, int min, int max)
{
Scanner s = new Scanner (words);
int counter = 0;
while (s.hasNext())
{
String word = s.next();
int wordLength = word.length();
if (wordLength>min && wordLength<max)
{
counter= counter + 1;
s.close();
}
}
return counter;
}
【问题讨论】:
-
我完全不清楚你在问什么。你的英文措辞很混乱。问题是什么?错误在哪里?
-
你能帮我翻译一下吗? “我正在尝试编写一种方法,该方法从“words”参数中返回至少具有最小字符但不超过“最大 c”字符的单词数。”
-
大声笑,我复制并粘贴了说明,就像我被告知的那样。但是我试图在字符串(单词)中找到至少有一定数量的字符(min)并且不超过一定数量的字符(max)的单词。希望这更有意义
-
这里有什么问题?
-
我的导师给出了测试用例,根据这些测试用例有问题,所以我希望能得到一些帮助