aspose file tools*
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 Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Equality of String objects" Watch "Equality of String objects" New topic
Author

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:

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


<a href="http://www.bryantimmins.com" target="_blank" rel="nofollow">Bryan Timmins</a> <br />SCJP2
Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 761

see http://www.javaranch.com/ubb/Forum1/HTML/000946.html


Regards,

Pho
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: http://aspose.com/file-tools
 
subject: Equality of String objects
 
Similar Threads
cloning
String equvalence....
String & String Buffer
String equvalence....
Why 'equals' methods were not overridden in StringBuffer and StringBuilder?