the output is : Different content. I thought it would be Same content.
Well, since your "Reference" class doesn't override the equals() method, you are using the equals() method implementation from the Object class. The implementation of the equals() method of the Object class returns true only if the two objects are the exact same instance.
If you dont override the equals() method that you have inherited from the Object class, you would get this result. Object class equals() method does nothing but returns true if references to the two objects are same. In your case you created two objects and references to both objects are different so they are different, and equals returns false.
Try this code if you want result true if you use equals to compare objects of class Reference:
But you would often want to give your equals method a deeper meaning that what I have done.
The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).