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

Convenience method for generic array copying

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3.0, 1.4.0
    • 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.)

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: