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");
}
}
我试图提示用户输入一个数字,但我无法让它正确运行。我希望它继续运行,直到输入正确的输入。