Java examples for Reflection:Class Name
get Simple Class Name
//package com.java2s; public class Main { public static void main(String[] argv) { Class aClass = String.class; System.out.println(getSimpleClassName(aClass)); }//from www .java2 s .co m public static String getSimpleClassName(Class aClass) { return getSimpleClassName(aClass.getName()); } public static String getSimpleClassName(String qualifiedClassName) { return getLastToken(qualifiedClassName, '.'); } public static String getLastToken(String str, char separator) { int pos = str.lastIndexOf(separator); if (pos != -1) { str = str.substring(pos + 1); } return str; } }