• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Internal implementation of equals

 
Neelima Mohan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 15369
40
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Muhammad Khojaye
Ranch Hand
Posts: 449
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I find http://www.docjar.com/ to be useful for looking the classes source code.
 
Neelima Mohan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey thanks!
 
Tracy Tse
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Campbell Ritchie
Sheriff
Pie
Posts: 49472
64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic