• 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

solve StringBuilder problem

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

class MainClass {




public static void main (String [] args) {
String s1 = new String("hello world");
String s2 = new String("hello world");
System.out.println(s1.equals(s2));

StringBuilder sb1 = new StringBuilder("hello world");
StringBuilder sb2 = new StringBuilder("hello world");
System.out.println(sb1.equals(sb2));


}

}
 
Ranch Hand
Posts: 446
1
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is your question?
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gaurav , Welcome to JavaRanch

Please UseCodeTags for posting the source code and also TellTheDetails

(Please note: the dotted line under the specific words above would lead to the link which explain more about them)
 
Ranch Hand
Posts: 448
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

equals method is not overridden in StringBuffer/StringBuilder classes but is overridden in String class.

Check java doc
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic