How can i get the name of the class
String.class.getName() returns java.lang.String
I am only interested in getting last part ie only String
Any Api can do that?
getName() returns the name of the entity (class, interface, array class, primitive type, or void) represented by this Class object, as a String.
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.
String className = this. getClass(). getSimpleName(); This will work as long as you don't use it in a static method.
To get the class name of an instance in Python: Use the type() function and __name__ to get the type or class of the Object/Instance. Using the combination of the __class__ and __name__ to get the type or class of the Object/Instance.
Class.getSimpleName()
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