以下のコードで私を助けてください。エラーは次のとおりです。あなたは、静的メソッド(静的コンテキスト)でこれを使用することはできませんJavaでこれは静的コンテキストでは使用できません
public class Sample2 {
/**
* @param args
*/
public static void main(String[] args)
{
Sample2 sam=new Sample2();
//Below code works fine
System.out.println(sam);
//Below code is displaying error
System.out.println(this);
}
}
[static以外の変数は静的コンテキストから参照できません](http://stackoverflow.com/questions/2559527/non-static-variable-cannot-be-referenced-from-a-static-コンテキスト) –
[なぜ静的メソッドでこのキーワードを使用できないのですか?](http://stackoverflow.com/questions/11664522/why-cant-we-use-this-keyword-in-a-static -method) – fglez
これは役に立つかもしれません - http://www.buggybread.com/2014/06/error-cannot-use-this-in-static-context.html –