while (goodInput=false)
{
try
{
System.out.println("How long is the word you would like to guess?");
wordSize=scan.nextInt();
while(wordSize>word.longestWord())
{
System.out.println("There are no words that big! Please enter another number");
wordSize=scan.nextInt();
}
goodInput=true;
}
catch(InputMismatchException ime)
{
System.out.println("Thats not a number! Try again");
}
}
我想提示用户输入号码,但我不能让它正确运行。我希望它保持运行,直到输入正确的输入。提示用户,直到输入正确的输入类型
目前会发生什么? – OmniOwl
“我无法让它正常运行”是**不是一个真正的问题。 –
非常感谢马克。发生了什么是它捕捉到错误,然后进入该段之后的下一行。我认为南巴里所说的是什么错误。 – jeanqueq