我無法理解它。線程「main」中的異常java.lang.Error:未解決的編譯問題:局部變量xxx可能尚未初始化
我的錯誤
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The local variable time may not have been initialized
The local variable time may not have been initialized
at earth.main(earth.java:15)
我的編碼
public class Earth {
public static void main(String[] args) {
// TODO Auto-generated method stub
int time ;
int distance;
int speed ;
distance = 150000000;
speed = 300000;
distance = speed * time;
System.out.println(+time);
}
}
你不會學習如何在這裏問一個問題,你所得到的每編譯錯誤的代碼。購買一本書,閱讀它,閱讀錯誤信息並嘗試理解它,然後使用Google來查明是否卡住了。如果它不編譯,請停止運行你的代碼。在Eclipse中打開「Problems」視圖,甚至沒有想到在該視圖中列出錯誤時運行代碼。 Eclipse已經收到警告,但忽略了警告。你從編譯器中得到錯誤,但選擇不讀取它們。這不會讓你走得很遠。錯誤信息必須被讀取。 –
謝謝,我感謝你 – user3475322