Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

string buffer

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there any way to compare stringbuffer's???
coz this is not working???
StringBuffer sb1 = new StringBuffer("java");
StringBuffer sb2= new StringBuffer("java");
String ss1 = "java";
System.out.println(sb1==sb2);
System.out.println(sb1.equals(sb2));
 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Srinivas!
I must admit that I am deeply confused as I thought that the StringBuffer class had overriden the original equals() method which is inherited from the Object class, but after looking in the java docs I found out that it doesn't!
But here is one way to deal with it:
System.out.println(sb1.toString().equals(sb2.toString()));
Regards
------------------
Dominic Steng�rd
Sun Certified Java 2 Programmer
------------------
 
srinivas bolloju
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks you dominic , c u in next question !!!
 
I'm sure glad that he's gone. Now I can read this tiny ad in peace!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic