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