java錯誤Cannot make a static reference to the non-static method

轉: 我在一個類中寫了一個public void getDate()方法和一個main方法,在main方法中直接調用getDate()方法,於是就出現了這個錯誤提示。后來實例化類,再用實例化的類調用getDate()方法就沒問題了。 在靜態方法中,不能直接訪問非靜態成員(包括方法和變量 ...

Sun Apr 22 23:41:00 CST 2012 1 5663
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM