• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

equals() in StringBuffer

 
jordan gong
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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");
System.out.println(s1.equals(s2));
The code returns false. I could not understand it? Help please.
 
Jane Griscti
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic