| Author |
== Vs .equals()
|
Clarence J M Tauro
Ranch Hand
Joined: Aug 09, 2008
Posts: 30
|
|
Consider the following code
Is it the same, considering that the Object class's .equals() method being invoked?
|
 |
Steve Luke
Bartender
Joined: Jan 28, 2003
Posts: 3026
|
|
That depends on the runtime type of a.
|
Steve
|
 |
Clarence J M Tauro
Ranch Hand
Joined: Aug 09, 2008
Posts: 30
|
|
|
Ha ha, Nice way to answer. Thanks a lot..
|
 |
Anirudh Aithal
Greenhorn
Joined: Jun 09, 2009
Posts: 7
|
|
I found a nice article about this:
http://www.ccnyddm.com/JavaBook/EqualsEtc.htm
|
Regards,
Anirudh
|
 |
Raj chiru
Ranch Hand
Joined: Aug 12, 2008
Posts: 140
|
|
The default behaviour (default implementation) of equals() is to do == comparisions.
if you do't override the equals() in a class ,no two objects can ever be consider equal since references to two different objects will always contain a
different pattern (i.e hash value is different)
|
 |
Chitta Ranjan Mahato
Ranch Hand
Joined: Jun 20, 2009
Posts: 38
|
|
|
|
 |
Raj chiru
Ranch Hand
Joined: Aug 12, 2008
Posts: 140
|
|
|
In case of Wrapper classes it's true
|
 |
 |
|
|
subject: == Vs .equals()
|
|
|