Why does StringBuffer/StringBuilder does not override the equals(), hashcode() methods from object?
Please suggest me clear picture that helps the understand the problem…
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Because
StringBufferis mutable, and its primary use is for constructing strings. If you want to compare content, callStringBuffer#toString()and compare the returned value.It is not generally useful to override
hashCode()for mutable objects, since modifying such an object that is used as a key in aHashMapcould cause the stored value to be “lost.”