Breaking

Sunday, April 26, 2020

Can “this” keyword be used within a static method?

Since “this” keyword returns a reference to the current instance of a class, so we cannot use this inside a static method. And static members exist without any instance of the class and call with the name of the class, not by instance. So, we can say that “this” keyword is a special type of reference variable that is implicitly defined within each constructor and non-static method as a first parameter of the type class in which it is defined.

No comments:

Post a Comment