USE REFLECTION FOR EASY TOSTRING() IMPLEMENTATIONS Implementing toString() methods is often useful for debugging purposes, but it can be time consuming for objects with large field counts. By taking advantage of the Java Reflection API, you can build an easy and flexible toString() method. The sample toString() method below will print out all the fields of its implementing class. It works by obtaining a list of Field objects through the Reflection API and then calling an implicit toString() on those objects by appending them to a StringBuffer. This code should work in JDK 1.1 and up and can be used by pasting it into any class: public String toString() { StringBuffer sb = new StringBuffer(); java.lang.reflect.Field[] fld = getClass().getDeclaredFields(); sb.append(getClass().getName()+"\n"); for (int i = 0; i < fld.length; i++) { try {sb.append(">"+fld[i].getName()+","+fld[i].get(this)+"\n");} catch (IllegalAccessException e) {} } return sb.toString(); } If you want to avoid adding this method to all your classes, you could create a single static method in a utility class that would generate a description of the field values for any object passed to it. Since you would be attempting to read field values from another class, you would also need to add the setAccessible method if you want to read protected or private fields, which would otherwise be hidden, as shown in this implementation: public static String getDescString(Object obj) { StringBuffer sb = new StringBuffer(); java.lang.reflect.Field[] fld = obj.getClass().getDeclaredFields(); java.lang.reflect.AccessibleObject.setAccessible(fld, true); sb.append(obj.getClass().getName()+"\n"); for (int i = 0; i < fld.length; i++) { try {sb.append(">"+fld[i].getName()+","+fld[i].get(obj)+"\n");} catch (IllegalAccessException e) {} } return sb.toString(); } The Reflection API can be a powerful tool; you may want to explore ways to extend this simple example by describing an object's superclass field values as well, or by calling toString() methods on field values that are objects in their own right, such as arrays. ------------------------------------------