Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • 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
Sheriff
Posts: 15715
73
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
Marshal
Posts: 52664
122
  • 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.
 
This parrot is no more. It has ceased to be. Now it's a tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!