由于继续外循环错误,我无法运行此代码。
我在网上查了一下,发现人们因为多了一个分号而遇到了问题。我没有那个问题,但我仍然收到此错误。
public class GuessingGame {
int random;
public void generateNumber()
{
//The following lines generate and output a random number between 1 and 10
random = (int)(Math.random()*10)+1;
}
//Write the guess() method below
public void guess()
{
//Use scanner to accept a user input
//Create a new scanner object to receive user input
Scanner sc=new Scanner(System.in);
System.out.println("Enter you guess between 1 to 10");
int guess = sc.nextInt();
//write your code below
if (guess == random){
System.out.println("You guessed it right, the number is " + random);
} else if (guess<random) {
System.out.println("You guessed too low!");
continue;
} else {
System.out.println("You guessed too low");
continue;
}
}
每当我运行它时,我都会收到此错误。错误:(35, 12) java: 在循环外继续
狐的传说
qq_遁去的一_1
慕哥6287543
莫回无
相关分类