Would what be a static equivalent of a dynamic
String CLASS_NAME = this.getClass().getCanonicalName()
Note that the following is not what i'm looking for since it specifically refers to a particular class. I'd like to refer to class name outside of a method (ie in the static {} section)
static String CLASS_NAME = Foo.class.getCanonicalName()
THanks.
You can see that in the main method, or in any instance method, I am capable to get the name of the generics type, in this case the main will print: java. lang. Integer. ...and you get the name of the subclass (if any).
Generic Classes These classes are known as parameterized classes or parameterized types because they accept one or more parameters.
A Generic class simply means that the items or functions in that class can be generalized with the parameter(example T) to specify that we can add any type as a parameter in place of T like Integer, Character, String, Double or any other user-defined type.
If you have a JavaSW object, you can obtain it's class object by calling getClass() on the object. To determine a String representation of the name of the class, you can call getName() on the class.
Not sure if I understand your question - did you try this.getClass().getCanonicalName()
?
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