i have to read the current class name inside a static method. For non-static method it's easy i just call getQualifiedClassName(this) but inside a static method this is off course invalid. Any idea ?
Thanks
The simplest way is to call the getClass() method that returns the class's name or interface represented by an object that is not an array. We can also use getSimpleName() or getCanonicalName() , which returns the simple name (as in source code) and canonical name of the underlying class, respectively.
Since static variables belong to a class, we can access them directly using class name. So, we don't need any object reference. We can only declare static variables at the class level. We can access static fields without object initialization.
A static method can be called directly from the class, without having to create an instance of the class. A static method can only access static variables; it cannot access instance variables. Since the static method refers to the class, the syntax to call or refer to a static method is: class name.
You can use getQualifiedClassName(prototype.constructor) in the class' static method
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With