Meaningless Drivel is fun!
The moose likes Mock Exam Errata and the fly likes equals() in StringBuffer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Mock Exam Errata
Bookmark "equals() in StringBuffer" Watch "equals() in StringBuffer" New topic

equals() in StringBuffer

jordan gong
Ranch Hand

Joined: Jun 12, 2001
Posts: 37
Can anybody explain why the equals() method in StringBuffer is not overriden?
Assuming in main() block:
StringBuffer s1=new StringBuffer("hello");
StringBuffer s2=new StringBuffer("hello");
The code returns false. I could not understand it? Help please.
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Hi Jordan,
I've never come across any reason why <code>equals()</code> isn't overridden in <code>StringBuffer</code>; just that it isn't.
Not much help, I know ... you just need to remember that <code>String</code> and the Wrapper classes overload <code>equals()</code> and that <code>StringBuffer</code> doesn't.

Jane Griscti
Sun Certified Programmer for the Java� 2 Platform

Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
I agree. Here's the link:
subject: equals() in StringBuffer
It's not a secret anymore!