Class ArrayCopy


  • public final class ArrayCopy
    extends Object
    The copyOf methods on java.util.Arrays are introduced in Java6. Need an alternative to support Java5.
    • Method Detail

      • copyOf

        public static final <E> E[] copyOf​(E[] source,
                                           int len)
        Arrays.copyOf(...) is a Java6 thing. This is a replacement.
        Type Parameters:
        E - The generic type of the array we are copying.
        Parameters:
        source - the source array.
        len - the length of the new array copy.
        Returns:
        a new array that has the same elements as the source.
      • copyOfRange

        public static final <E> E[] copyOfRange​(E[] source,
                                                int from,
                                                int to)
        Arrays.copyOf(...) is a Java6 thing. This is a replacement.
        Type Parameters:
        E - The generic type of the array we are copying.
        Parameters:
        source - the source array.
        from - the start point of the copy (inclusive).
        to - the end point of the copy (exclusive).
        Returns:
        a new array that has the same elements as the source.
      • copyOf

        public static final char[] copyOf​(char[] source,
                                          int len)
        Arrays.copyOf(...) is a Java6 thing. This is a replacement.
        Parameters:
        source - the source array.
        len - the length of the new array copy.
        Returns:
        a new array that has the same elements as the source.
      • copyOf

        public static final int[] copyOf​(int[] source,
                                         int len)
        Arrays.copyOf(...) is a Java6 thing. This is a replacement.
        Parameters:
        source - the source array.
        len - the length of the new array copy.
        Returns:
        a new array that has the same elements as the source.
      • copyOf

        public static final boolean[] copyOf​(boolean[] source,
                                             int len)
        Arrays.copyOf(...) is a Java6 thing. This is a replacement.
        Parameters:
        source - the source array.
        len - the length of the new array copy.
        Returns:
        a new array that has the same elements as the source.