Java Class Simple Name Get simpleClassNameOf(Class c)

Here you can find the source of simpleClassNameOf(Class c)

Description

Since Class.getSimpleName() method is not supported by GWT JRE.

License

Open Source License

Parameter

Parameter Description
The class.

Declaration

public static String simpleClassNameOf(Class<?> c) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**// w  w  w  .  ja v  a2 s  .co m
     * Since Class.getSimpleName() method is not supported by GWT JRE. This method is to retrieve the simple name of the
     * class, which the last token of the full class name separated by dot.
     * 
     * @param The
     *            class.
     * @return
     */
    public static String simpleClassNameOf(Class<?> c) {
        String cname = c.getName();
        return cname.substring(cname.lastIndexOf('.') + 1);
    }

    public static String simpleClassNameOf(Object o) {
        return simpleClassNameOf(o.getClass());
    }
}

Related

  1. simpleClassName(Object object)
  2. simpleClassName(String fqn)
  3. simpleClassNameAndHashCodeString(Object object)
  4. simpleClassNameAndHashCodeString(Object object)
  5. simpleClassNameFrom(String fqClassName)
  6. simpleName(Class clazz)
  7. simpleName(Class c)
  8. simpleName(final Class className)
  9. simpleName(final String fqn)