aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Stringbuffer? 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 » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Stringbuffer?" Watch "Stringbuffer?" New topic
Author

Stringbuffer?

srikanth reddy
Ranch Hand

Joined: Jul 28, 2005
Posts: 252


hi friends,

the first two System.out.println statements are printing false....
do they follow different from what strings follow??
can anyone clarify my doubt??

thanks

srikanth
agrah upadhyay
Ranch Hand

Joined: Sep 01, 2005
Posts: 579

For StringBuffer class,equals() method is not overridden as for String class{which tests for content and NOT reference).So For StringBuffer,== and equals() behaves in same manner.Right?


<i>--Agrah Upadhyay--</i><br />Final Year B.Tech SCJP,SCWCD,SCBCD <br /> <br /><b>Now since the real test for any choice is having to make the same choice again,knowing full well what it might cost.</b>-Oracle
Rishi Chopra
Ranch Hand

Joined: Mar 07, 2004
Posts: 108
StringBuffer do not override eqauls method present in Object class
so will get the same method that the object class has..
and Object class has equals method that perfomrs == comparison underneath

so the result of sb1.eqausl(sb2) will b same as sb1==sb2 which in this case is false.

hope this helps
Rgds


Life is Beautiful Learn to See it.........
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Stringbuffer?
 
Similar Threads
Question on String Buffer
question about StringBuffer
String Buffer
string(buffer) comparision...
strings