Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5082260

StringBuffer should implement equals(Object), should take String, CharSequence

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 5.0
    • core-libs
    • x86
    • windows_xp



      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)
      ======================================================================

            martin Martin Buchholz
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: