Java Class get Short Class Name

Description

Java Class get Short Class Name


public class Main {
    public static void main(String[] argv) throws Exception {
        String className = "java.lang.String";
        System.out.println(getShortClassName(className));
    }/* ww w .  j  ava2s. com*/

    public static String getShortClassName(String className) {
        if (className == null)
            return null;
        int index = className.lastIndexOf(".");
        return className.substring(index + 1);
    }
}



PreviousNext

Related