Java Utililty Methods Class Name Get

List of utility methods to do Class Name Get

Description

The list of methods to do Class Name Get are organized into topic(s).

Method

Stringclassname(Class javaClass)
classname
String jClassName = javaClass.getName();
return classname(jClassName);
StringclassName(Class type)
Returns the class formatted as a string.
if (type.isArray()) {
    Class elementClass = getElementClass(type);
    StringBuilder buffer = new StringBuilder(16);
    for (int i = 0, n = getDimensionCount(type); i < n; i++)
        buffer.append("[]");
    return className(elementClass) + buffer;
if (type.isPrimitive() || type == Object.class || type == Boolean.class || type == Byte.class
...
StringclassName(Class aClass)
class Name
if (aClass == null)
    return null;
final String cn = aClass.getName();
int idx = cn.lastIndexOf('.');
return (idx > 0) ? cn.substring(idx + 1) : cn;
StringclassName(final Class c)
Get an easy-to-use representation of a class.
String s;
if (c == null) {
    return "No class specified."; 
s = c.getCanonicalName();
if ((s != null) && (s.length() > 0)) {
    return s;
s = c.getName();
if ((s != null) && (s.length() > 0)) {
    return s;
s = c.getSimpleName();
if ((s != null) && (s.length() > 0)) {
    return s;
s = c.toString();
if ((s != null) && (s.length() > 0)) {
    return s;
return "nameless"; 
StringclassName(final Object object)
Returns the class name of the specified object, excluding its path.
return className(object.getClass());
StringclassName(Object o)
class Name
if (o == null) {
    return "";
String s = o.getClass().getName();
int i = s.lastIndexOf('.');
if (i >= 0) {
    return s.substring(i + 1);
} else {
...
StringclassName(Object o)
Readable class name (i.e., not unqualified)
if (null == o) {
    return "NOCLASS";
if (o instanceof Class) {
    return ((Class<?>) o).getSimpleName();
return o.getClass().getSimpleName();
StringclassName(Object obj)
class Name
return classShortName(obj.getClass());
Stringclassname(Object obj)
classname
if (obj != null && obj.getClass().getEnclosingClass() == null) {
    return obj.getClass().getSimpleName();
} else {
    return null;
StringclassName(Object object)
null safe classname method
return object == null ? null : object.getClass().getName();