| Author |
Internal implementation of equals
|
Neelima Mohan
Greenhorn
Joined: May 23, 2010
Posts: 27
|
|
Hi,
Just wanted to know how equals() method in String class is implemented?
anybody got a chance to look at the original implementation?
Thanks,
Neelima
|
 |
Danish Sualeh
Greenhorn
Joined: Oct 06, 2005
Posts: 11
|
|
Downloading the source code would be the best thing to do.
Is there any specific doubt that you have in mind regarding the implementation of equals method ?
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12907
|
|
|
You don't even need to download the source code separately; you can find it in the src.zip file that's in your JDK installation directory.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Muhammad Khojaye
Ranch Hand
Joined: Apr 12, 2009
Posts: 341
|
|
|
I find http://www.docjar.com/ to be useful for looking the classes source code.
|
http://muhammadkhojaye.blogspot.com/
|
 |
Neelima Mohan
Greenhorn
Joined: May 23, 2010
Posts: 27
|
|
hey thanks!
|
 |
Tracy Tse
Greenhorn
Joined: May 24, 2010
Posts: 22
|
|
Jesper Young wrote:You don't even need to download the source code separately; you can find it in the src.zip file that's in your JDK installation directory.
yes,right there , afer i reading the source code, i found it quite straightforward.
First of all ,test if the two object refers to the same one,if not,then check out the characters one by one .
Below is the implementation details.
Hope this helps!
|
Whatever it takes is what i have got !
Lift is the best sitcom!
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32599
|
|
Tracy Tse wrote: . . . First of all ,test if the two object refers to the same one,if not,then check out the characters one by one . . . .
You missed out the middle stage: check whether the other object is a String. Since String is a final class, it is safe to use instanceof.
|
 |
 |
|
|
subject: Internal implementation of equals
|
|
|