• Post Reply Bookmark Topic Watch Topic
  • New Topic

Object.equals() vs String.equals()  RSS feed

 
somin bhuvan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

What is the difference between Object.equals() and String.equals(), how this method internally works for both the classes.

- bhuvan
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In you downloaded the SDK from Sun, it came with a zip file of source code, src.zip.
By all means unzip it and poke though it! In it you'll find that Object's equals
method is defined as:

And String's equals method is defined as:

As the API states: The result is true if and only if the argument is not null and is a String
object that represents the same sequence of characters as this object.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!