This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Does StringBuffer overrides equals()!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Does StringBuffer overrides equals()!!" Watch "Does StringBuffer overrides equals()!!" New topic
Author

Does StringBuffer overrides equals()!!

natarajan meghanathan
Ranch Hand

Joined: Feb 01, 2001
Posts: 130
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.


Sun Certified Programmer for Java 2 Platform
Val Dra
Ranch Hand

Joined: Jan 26, 2001
Posts: 439
yes it doesn't overwride it.


Val SCJP <BR>going for SCJD
Sean Casey
Ranch Hand

Joined: Dec 16, 2000
Posts: 625
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

Joined: Jan 12, 2001
Posts: 63
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


Sun Certified programmer for Java2 platform.<BR>Shri_mk@hotmail.com
 
Consider Paul's rocket mass heater.
 
subject: Does StringBuffer overrides equals()!!
 
Similar Threads
string buffer
String Q
String buffer
Stringbuffer?
StringBuffer