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

StringBuffer needs more methods

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.1.4
    • core-libs
    • None
    • x86
    • windows_95



      Name: bk70084 Date: 10/24/97


      This is a problem I have ran into repeatedly. We all know that for speed optimization that
      concatenating Strings using the + operator is an expensive operation. The solution is of
      course to use a StringBuffer to avoid creation of new temporary objects. But, if I use a
      StringBuffer I suddenly lose most of the methods in the String class. In my particular
      program I need to repeatedly search the contents of the String in addition to modifying
      it. But StringBuffer has no search methods. I can use the toString method on the
      StringBuffer to make a String that I can then search, but I'm back to creating an
      unnecessary temporary object in addition to complicating the logic of the program.
      StringBuffer should support nearly all of the same methods as the String class in
      particular searching and comparison.

      In an ideal world String and StringBuffer should both be subclasses of a common abstract
      class that defines these methods common to both. I realize it is much too late to make a
      change like that, but would'nt be that hard to add these methods to StringBuffer to make
      it more usable. It would still be 100% compatible with current software.
      ======================================================================

            apalanissunw Anand Palaniswamy (Inactive)
            bklocksunw Brian Klock (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: