Possible Duplicate:
What is the reason behind 「non-static method cannot be referenced from a static context」?
Cannot make a static reference to the non-static method
cannot make a static reference to the non-static field無法從我無法理解什麼是錯我的代碼類型二
使靜態參考非靜態方法FXN(INT)。
class Two {
public static void main(String[] args) {
int x = 0;
System.out.println("x = " + x);
x = fxn(x);
System.out.println("x = " + x);
}
int fxn(int y) {
y = 5;
return y;
}
}
異常在線程「主要」 java.lang.Error的:未解決的問題,編譯: 無法從類型使靜態參考非靜態方法FXN(INT)兩個
不是你的低調選民,但你會想通過[Java教程](http://docs.oracle.com/javase/tutorial/reallybigindex。HTML)或一本基礎教科書來學習Java的基礎知識。 – 2012-07-15 12:12:20
如果您不瞭解我現在處於的狀況,請不要投下這個問題。 :/ 我仍然在Head First Java的第4章,並且對關於回報的陳述感到困惑。我只是想做到這一點。 – kunal 2012-07-15 12:36:44
在問這個問題之前,你應該先搜索一下答案。 – 2012-07-15 13:03:41