Your preferences have been saved!
» Gets the toString that would be produced by Object if - import java.io.Serializable; /**  * <p>Operations on <code>Object</code>.</p>  *   * <p>This class tries to handle <code>null</code> input gracefully.  * An exception will generally not be thrown for a <code>null</code> input.  * Each method documents its behaviour in more detail.</p>  *  * @author <a href="mailto:nissim@nksystems.com">Nissim Karpenstein</a>  * @author <a href="mailto:janekdb@yahoo.co.uk">Janek Bogucki</a>... 17 Feb 12 » Gets the toString of an Object returning an empty string - import java.io.Serializable; /**  * <p>Operations on <code>Object</code>.</p>  *   * <p>This class tries to handle <code>null</code> input gracefully.  * An exception will generally not be thrown for a <code>null</code> input.  * Each method documents its behaviour in more detail.</p>  *  * @author <a href="mailto:nissim@nksystems.com">Nissim Karpenstein</a>  * @author <a href="mailto:janekdb@yahoo.co.uk">Janek Bogucki</a>... 17 Feb 12 » Array To String - import java.io.PrintWriter; import java.io.StringWriter; import java.net.InetAddress; import java.net.URI; import java.net.URISyntaxException; import java.net.UnknownHostException; import java.text.DateFormat; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays;... 17 Feb 12 » toString(Object[] array) - /**  * @version $Revision: 1.1 $  */ public final class ToString {     public static String toString(Object[] array)     {         StringBuffer buffer = new StringBuffer();         Class type = array.getClass().getComponentType();         if (type != Object.class)... 17 Feb 12 » Null Safe To String - import java.lang.reflect.Array; import java.util.Arrays; abstract class ObjectUtils {   private static final int INITIAL_HASH = 7;   private static final int MULTIPLIER = 31;   private static final String EMPTY_STRING = "";   private static final String NULL_STRING = "null";   private static final String ARRAY_START = "{";   private static final String ARRAY_END = "}";   private static final String EMPTY_ARRAY = ARRAY_START + ARRAY_END;... 17 Feb 12 » Constructs pretty string representation of object value - import java.lang.reflect.Array; import java.util.Collection; import java.util.Iterator; import java.util.Map; /**  * Constructs pretty string representation of object value.  */ public class PrettyStringBuilder {   protected int maxArrayLen = 10;   protected int maxDeep = 3;... 17 Feb 12 » Use a generic toString() - import java.lang.reflect.Field; public class Main {   public static void main(String args[]) {     System.out.println(new MyClass().toString());   } } class MyClass {   String hello = "hi";   int i = 0;   public String toString() {... 17 Feb 12 » Reflection based toString() utilities - import java.lang.reflect.Field; public class Main {   String hello = "world";   int i = 42;   public static void main(String args[]) {     System.out.println(Util.toString(new MyClass()));          System.out.println(Util.toString(new MyAnotherClass()));   } }... 17 Feb 12 » To String Demo - public class ToStringDemo {   public static void main(String[] args) {     double d = 858.48;     String s = Double.toString(d);     int dot = s.indexOf('.');     System.out.println(s.substring(0, dot).length()         + " digits before decimal point.");     System.out.println(s.substring(dot + 1).length()         + " digits after decimal point.");   }... 17 Feb 12 » Demonstrate toString() without an override - /* Demonstrate toString() without an override */ public class ToStringWithout {   int x, y;   /** Simple constructor */   public ToStringWithout(int anX, int aY) {     x = anX; y = aY;   }   /** Main just creates and prints an object */   public static void main(String[] args) {      System.out.println(new ToStringWithout(42, 86));... 17 Feb 12