Java examples for Reflection:Class
get Inner Outer Classes
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { Class classInstance = String.class; getInnerOuterClasses(classInstance); }/*from w w w . j a va 2 s.co m*/ 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 if (ctmp != null) System.out.println(ctmp.getName()); } }