當我嘗試運行它時,它說console.readLine();
存在問題。console.readLine();錯誤;但在代碼中看起來都正確嗎?
import java.io.Console;
public class PingPong {
public static void main(String[] args) {
System.out.println("give me a number, honey?");
String stringYourNumber = console.readLine();
Integer yourNumber = Integer.parseInt(stringYourNumber);
System.out.println("Here ya go:");
for (Integer i=1; i <=yourNumber; i++){
if(i % 5==0 && i % 3==0){
System.out.println("PingPong");
} else {
if (i % 5==0){
System.out.println("Pong");
} else {
if (i % 3==0){
System.out.println("Ping");
}
}
}
}
}
它是否說_some problem_或**這個具體的問題就在這裏,這個錯誤信息發生這個原因**? –
PingPong.java:8:錯誤:找不到符號 \t \t String stringYourNumber = console.readLine(); \t \t^ 符號:變量控制檯 位置:類乒乓 1錯誤 –
請與相關的信息來更新您的問題,並解釋你不理解的錯誤消息。 –