Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

equals() method of StringBuffer

807589Jun 26 2008 — edited Jun 27 2008
Hello!

I'd like to ask you why the equals() method of StringBuffer is inherited directly from the Object class, and hence it just check for reference equality, and not being overriden as is the case with other classes.
For example:
 StringBuffer sb1=new StringBuffer("test");
 StringBuffer sb2=new StringBuffer("test");
 System.out.println(sb1.equals(sb2)); // will print false!
Thank you in advance
With best regards,
Sorin Ciolofan
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 25 2008
Added on Jun 26 2008
25 comments
235 views