import java.lang.reflect.*; public class ClassLister { public static void main(String[] args) { for(int i = 0; i < args.length; i++) { try { Class c = Class.forName(args[i]); System.out.print(Modifier.toString(c.getModifiers()) + " "); System.out.print(c); // watch for java.lang.Object if (!(c.toString().equals("java.lang.Object"))) System.out.println(" extends " + c.getSuperclass()); Class[] interfaces = c.getInterfaces(); if (interfaces.length > 0) System.out.println(" implements "); for (int j = 0; j < interfaces.length; j++) { if (j < interfaces.length - 1) System.out.println(interfaces[j] + ","); else System.out.println(interfaces[j]); } System.out.println("{"); System.out.println(); // print the fields Field[] fields = c.getDeclaredFields(); for (int j = 0; j < fields.length; j++) { System.out.println(" " + fields[j] + ";"); } System.out.println(); // print the constructors Constructor[] constructors = c.getDeclaredConstructors(); for (int j = 0; j < constructors.length; j++) { System.out.println(" " + constructors[j] + " {}"); } System.out.println(); // print the methods Method[] methods = c.getDeclaredMethods(); for (int j = 0; j < methods.length; j++) { System.out.println(" " + methods[j] + " {}"); } System.out.println(); System.out.println("}"); } catch (Exception e) { System.err.println(e); } } } }