提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
获取简单的类名
//package com.nowjava;/**from 时 代 Java - nowjava.com**/ public class Main { public static void main(String[] argv) { Class aClass = String.class; System.out.println(getSimpleClassName(aClass)); } 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.