ObjectUtils.equals2 : 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;

        //one and three are different objects
        System.out.print("3) Check object references and not values >>>");
        System.out.println(ObjectUtils.equals(one, three));
    }
}

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

}
3) Check object references and not values >>>false
  Download:  CommonLangObjectUtils.equals2.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