Convenience method for generic array copying

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Duplicate
    • Priority: P4
    • None
    • Affects Version/s: 1.3.0, 1.4.0
    • Component/s: core-libs
    • None
    • generic
    • generic

         The code for copying an array with Object.clone is a bit cumbersome. Once generics are added to the language, it will be possible to do better. The following method could be added to Arrays:

          public static <T>[] copy(<T>[] original);

      This would make it very easy to copy an array:

          Foo[] orig = ... ;

          ...

          Foo[] copy = Arrays.copy(orig); // No cast!

      (Internally, the new method would use Object.clone.)

            Assignee:
            Josh Bloch (Inactive)
            Reporter:
            Josh Bloch (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: