Win a 3 month subscription to Marco Behler Videos this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Equality of String objects  RSS feed

 
Bryan Timmins
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why is my brain melting on "equals()" vs. "=="?
The following prints out:

false
false
true
false

But I don't understand what makes
the StringBuffer objects behave differently. TIA

[This message has been edited by Bryan Timmins (edited August 07, 2001).]
 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
see http://www.javaranch.com/ubb/Forum1/HTML/000946.html
 
Bryan Timmins
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Pho Tek,
That link sums it up. I did just discover my answer on another group. I also discovered that String overrides hashCode() to return based on the contents of the String rather than the unique values normally associated with Object's hashCode().
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!