How can I get the classname at runtime, but only the classname?
Sebastian Wright
How can I get the classname at runtime, but only the actual classname and not the whole "com.xyz.etc." ?
I mean only the part of the name after the last period
22 Answers
You have to use this snippet code for object:
yourObject.getClass().getSimpleName();or for class use :
yourClass.class.getSimpleName();this code return only name of class, does not consist package name.
0String className = object.getClass().getSimpleName(); 0