Originally posted by saransh panda:
for comparison between two objects we can use
 operator 'obj1==obj2'
 function 'obj1.equals(obj2)'
but what is the difference between them? And if they represent the same funcationality what is the significance of equals() function?
the == operator actually tests the equality of the reference variables, that is, if the two variables are referring to the same object. To test the logical equality, that is, the equality of the object's state, we normally use the equals() method.
And welcome to the ranch
[ May 12, 2008: Message edited by: Balasubramanian Chandrasekaran ]
Originally posted by Vishal Pandya:
== checks wheather two object refernces points to same instance or not.
Whereas equals() compare the actual contents of two string objects.
This is true for Strings but not for all objects. If a class does not override the equals method then it will inherit the equals method from the Object class. The equals method in the Object class compares the two objects using ==.