Hi!
Mary Anitha is correct when she mentioned the difference between == & equals().
I would like to elaborate a bit more on this one.
In the class Object, equals() method behaves similar to the == operator. i.e. equals() returns true only if
this == object reference of parameter
All available classes in
java override the equals() method to compare the contents.
However, if you write your own class (by default it inherits from Object), the behaviour of equals() will be same as that of ==, unless you override equals() to compare contents rather than refernces.
I hope the above clears the difference between == & equals().
One point to remember is equals() method always check the types of the invoking object & the parameter passed. If the types are not the same, it returns false, no matter what the contents. Only if the types match, it goes for checking the contents.
[This message has been edited by Kav Bop (edited October 16, 2000).]