2017-05-27 5 views
-2

に私はこのコードのフラグメントについて質問がありますしかし、 "これ"を使わずに "a"を使うことはできますか?コンパイルエラーの適用範囲は、「この」javaの

写真:あなたは、インスタンスを持っていない静的方法でクラスのインスタンスへのhttps://www.dropbox.com/s/5q6y3ldsf37p0h3/%D0%97%D0%BD%D1%96%D0%BC%D0%BE%D0%BA%20%D0%B5%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202017-05-27%2017.28.34.png?dl=0

+1

これを読む[なぜ静的メソッドでthisキーワードを使用できないのですか?(https://stackoverflow.com/questions/11664522/why-cant-we-use-this-keyword-in-a-静的メソッド) –

答えて

1

このためポイント、。

The this keyword refers to the current instance of the class. Static member functions do not have a this pointer

あなたは静的メンバの定義はこのがポイントには何もしています理由です

Use the static modifier to declare a static member, which belongs to the type itself rather than to a specific object

でわかります。

関連する問題