Where you do this:
Class objectClass = obj.getClass();
String className = objectClass.getName();
// Just get the class name without the package structure
String[] tokens = className.split("\\.");
int lastToken = tokens.length - 1;
className = tokens[lastToken];
You just do this:
Class objectClass = obj.getClass();
String className = objectClass.getSimpleName(); |