This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Equality of String objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Equality of String objects" Watch "Equality of String objects" New topic

Equality of String objects

Bryan Timmins
Ranch Hand

Joined: Mar 26, 2001
Posts: 48
Why is my brain melting on "equals()" vs. "=="?
The following prints out:


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).]

<a href="" target="_blank" rel="nofollow">Bryan Timmins</a> <br />SCJP2
Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 776



Bryan Timmins
Ranch Hand

Joined: Mar 26, 2001
Posts: 48
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().
wood burning stoves
subject: Equality of String objects