提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
获得内部外部课程
/**来自 时 代 J a v a 公 众 号 - N o w J a v a . c o m**/ //package com.nowjava; public class Main { public static void main(String[] argv) throws Exception { Class classInstance = String.class; getInnerOuterClasses(classInstance); } public static void getInnerOuterClasses(Class<?> classInstance) { Class<?>[] cc = classInstance.getDeclaredClasses(); //inner classes for (Class cite : cc) System.out.println(cite.getName()); Class<?> ctmp = classInstance.getDeclaringClass(); //outer classes