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

resizing arrays

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P3 P3
    • None
    • 1.1.4
    • tools
    • x86
    • windows_95



      Name: bk70084 Date: 11/03/97


      Array resizing is something programmers often need
      to do.

      Right now, the best way to do it is:

      (1) allocate a new array and assign it to a new
          temporary variable
      (2) using the System.arraycopy method, copy the
          elements from the original array into the new
          array
      (3) assign the handle of the new array to the old
          variable

      This is tedious.

      Would it be cool if an array's "length" property
      was writable?

      int [] ar = new int [5];
      ...use ar for a while...
      ...decide it's time to make it an array of 10 elements...
      ar . length = 10;
      /* done */

      I think this is an interesting idea worth pursuing,
      and it would not compromise backward compatibility.

      Another alternative is to add a resize () method
      to all arrays.
      (Review ID: 19257)
      ======================================================================

            dstoutamsunw David Stoutamire (Inactive)
            bklocksunw Brian Klock (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: