ObjectUtils.toString : ObjectUtils « Apache Common « Java Tutorial






import org.apache.commons.lang.ObjectUtils;

public class MainClass {
    public static void main(String[] args) {
        //Create ObjectUtilsTrial instance
        MyClass one = new MyClass();
        MyClass two = one; //Same Reference
        MyClass three = new MyClass(); //New Object
        MyClass four = null;

        //Pass null get empty string
        System.out.print("6) Pass null and get back an Empty string >>>");
        System.out.println("**" + ObjectUtils.toString(null) + "**");

    }
}

class MyClass{
    public String toString() {
        return "toString Output";
    }

}
6) Pass null and get back an Empty string >>>****
  Download:  CommonLangObjectUtils.toString.zip( 199 k)








37.10.ObjectUtils
37.10.1.ObjectUtils.toString
37.10.2.ObjectUtils.identityToString
37.10.3.ObjectUtils.equals2
37.10.4.ObjectUtils.equals
37.10.5.ObjectUtils.defaultIfNull