0
我得到我的return语句“非法字符‘\ u600b’为下面的代码固定的“非法字符‘U \ 600B’”的错误:需要帮助的Java
public static int getNum() {
Scanner in = new Scanner(System.in);
int number;
boolean goodInput = true;
do {
goodInput = true;
try {
System.out.print("Please enter a positive number: "); // prompts the user
number = Integer.parseInt(in.nextLine()); // Tries to make the next input a number
} catch (Exception e) { // if it breaks
System.out.println("The number you entered was invalid."); // it tells the user it was wrong
goodInput = false; // and runs the loop again
}
if(number <= 0) { // makes sure that the number entered was valid
System.out.println("The number you entered was invalid.");
goodInput = false; // or it re runs the loop
}
}while (!goodInput)
return number;
}
任何一个知道如何解决这个问题?
我知道这可能听起来很奇怪,但是你可以删除return语句之前和之后的行以及return语句,然后重新键入它吗? (复制粘贴可能不起作用) – hexafraction
^^那。你有垃圾,不可打印的字符,你从某处复制和粘贴。 –
该死的,这是很奇怪的错误,我试图重现它,它“工作”,但我不知道为什么! – libik