Why does StringBuffer/StringBuilder does not override the equals()
, hashcode()
methods from object?
Please suggest me clear picture that helps the understand the problem...
See Question&Answers more detail:osWhy does StringBuffer/StringBuilder does not override the equals()
, hashcode()
methods from object?
Please suggest me clear picture that helps the understand the problem...
See Question&Answers more detail:osBecause StringBuffer
is mutable, and its primary use is for constructing strings. If you want to compare content, call StringBuffer#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 a HashMap
could cause the stored value to be "lost."