Jan 25, 2011

Java Simple Code

PHp var_dump for Java Equivalent



import java.lang.reflect.*;
....
//o Object..
Field[] fields = o.getClass().getDeclaredFields();
for (int i = 1; i < fields.length; i++
try {
System.out.println(fields[i].getName() + " - " + fields[i].get(o));
} catch (java.lang.IllegalAccessException e) {
System.out.println(e);
}

No comments: