This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
if the objects you are comparing have overridden equals method( from java.lang.Object class) then it depends upon your implementation. as to how you implements equals method for establishing the equality of two objects. say you have a Dog class with instance field as String breed, with getter for breed field. you can writer your equals method as follows : here we are establishing how 2 dog objects can be equal. we used breed instance field. you can use your own implementation. inside equals method , i call equals method on Sting. Since string class has already overridden equals method it can compare 2 strings and can return true, or false depending upon the literal string contained in the two string objects. also , if you don't override equals method then inherited equals method from the Object will run, which uses == operator for comparisons, which further means two references are only equal if they refer to same object.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Reference variables comparison using equals method