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 two point to the same object
System.out.print("2) References to the same object >>>");
System.out.println(ObjectUtils.equals(one, two));
}
}
class MyClass{
public String toString() {
return "toString Output";
}
}
|