可能重複:
What is the reason behind 「non-static method cannot be referenced from a static context」?非靜態方法不能被引用
import java.io.*;
public class Pay
{
boolean checkCard(int cardNumber)
{
boolean flag=false;
if(cardNumber==12)
return flag;
}
public static void main(String args[])throws SQLException
{
boolean f=checkCard(12);
System.out.println("\n Card Details "+f);
}
}
我得到錯誤味精說 非靜態方法checkCard(INT,字符串,字符串)不能從靜態環境中引用
請幫我一下
閱讀:[「瞭解實例和類成員」](http://docs.oracle.com/ javase/tutorial/java/javaOO/classvars.html) – Sujay
因爲目前還沒有數百個關於這個的SO問題...... –