Studyon Minte9.com
Java SE




Object Dump




package testexample; import java.lang.reflect.Field; public class Test { private String var1 = "a"; private int var2 = 1; public static void main(String[] args) throws Exception { Test test = new Test(); Field[] fields = test.getClass().getDeclaredFields(); // --- Look Here --- // for (int i=0; i<fields.length; i++) { String key = fields[i].toString(); String value = fields[i].get(test).toString(); System.out.println(key + " = " + value); } // Outputs: var1 = a , var2 = 1 } }
 


http://stackoverflow.com/questions/6478302/value-of-a-field-of-java-object-dynamically-by-reflection
http://docs.oracle.com/javase/tutorial/reflect/member/fieldValues.html