*
The moose likes Beginning Java and the fly likes Internal implementation of equals Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Internal implementation of equals" Watch "Internal implementation of equals" New topic
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
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14114
    
  16

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: 449

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: 38466
    
  23
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Internal implementation of equals