File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 REST with Spring (video course) this week in the Spring 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().
I agree. Here's the link:
subject: Equality of String objects
It's not a secret anymore!