Java tutorial
//package com.java2s; import java.lang.reflect.Field; public class Main { public static void classInspector(Object object) { Class cls = object.getClass(); System.out.println(cls.toString()); Field[] fieldlist = cls.getDeclaredFields(); for (int i = 0; i < fieldlist.length; i++) { Field fld = fieldlist[i]; System.out.println("name = " + fld.getName()); System.out.println("decl class = " + fld.getDeclaringClass()); System.out.println("type = " + fld.getType()); System.out.println("-----"); } } }