Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

equals method with stringbuffer

 
mukesh pandey
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
StringBuffer sb1 = new StringBuffer("Amit");
StringBuffer sb2 = new StringBuffer("Amit");

why

sb1.equals(sb2) = false ?

while

String s1 = new String("Amit");
String s2 = new String("Amit");

s1.equals(s2) = true
 
Vinoth Kumar Kannan
Ranch Hand
Posts: 276
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A search in this forum would have helped. We had this topic discussed recently.
http://www.coderanch.com/t/496567/java/java/Difference-equals-method-string-stringbuffer
Please search before posting a question..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic