Name: rmT116609 Date: 08/03/2004
A DESCRIPTION OF THE REQUEST :
Class java.lang.StringBuffer does not override method equals(Object). It
probably should define equals(...) to compare the string value currently
represented by the StringBuffer with the string value represented by the
argument.
It should obviously accept StringBufer objects.
It should accept String objects.
It should probably accept CharSequence objects.
Possibly it should also accept character array objects.
JUSTIFICATION :
Currently, there doesn't seem to be any efficient and convenient way to
compare the string represented by a string buffer with another string,
especially one represented by a String object.
You could use:
string.equals( stringBuffer.toString() )
but that (inefficiently) creates a second String object (which shouldn't be
necessary just to compare the represented strings).
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
See proposal in Description section.
ACTUAL -
See description of current (main) option in Justification section.
(Incident Review ID: 295726)
======================================================================
- relates to
-
JDK-8137326 Methods for comparing CharSequence, StringBuilder, and StringBuffer
- Resolved