Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Does StringBuffer overrides equals()!!

 
natarajan meghanathan
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just want to make sure whether the StringBuffer class overrides the equals() method of the Object class.
I say no. It doesn't override it.
So,
StringBuffer sb1 = new StringBuffer("Amit");
StringBuffer sb2= new StringBuffer("Amit");
sb1.equals(sb2) returns false.
 
Val Dra
Ranch Hand
Posts: 439
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes it doesn't overwride it.
 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Val is right. You really should consult the documentation for questions like this. It'll help you in the long run, if you familiarize yourself with the apis.
 
Shrini Kulkarni
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
StringBuffer class doesnot override equals(). That is when we use equals() for StringBuffers, what is done is just reference comparasion - the behaviour inherited from Object class. Boolean and String classes override equals() method. Thus when two strings are compared - comparison is done for equality of string contents not thier handles.
Shrinivas
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic