• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

equals() in StringBuffer

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
We cannot change unless we survive, but we will not survive unless we change. Evolving tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic