user3342795
user3342795

Reputation: 105

Refering a class in a static method

Is there a way to refer java to the current class in a static method? I usually use the word "this", but this is obviously not working.. Any help?

Upvotes: 0

Views: 67

Answers (1)

Jeroen Vannevel
Jeroen Vannevel

Reputation: 44439

this points to the current instance, not the current class.

For this reason, this will never work in a static context.

If you want to use the current class, you'll have to explicitly name it as MyClass.

Upvotes: 3

Related Questions