Android Array Copy copyOf(T[] original)

Here you can find the source of copyOf(T[] original)

Description

Copy the specified array.

Parameter

Parameter Description
original array.

Return

copy of original.

Declaration

public static <T> T[] copyOf(T[] original) 

Method Source Code

//package com.java2s;

public class Main {
    /** // www  .j a v  a2s .co m
     * Copy the specified array.
     * @param original array.
     * @param newLength new array length.
     * @return copy of original.
     */
    public static <T> T[] copyOf(T[] original, int newLength) {
        T[] copy = (T[]) new Object[newLength];
        System.arraycopy(original, 0, copy, 0,
                Math.min(original.length, newLength));
        return copy;
    }

    /**
     * Copy the specified array.
     * @param original array.
     * @return copy of original.
     */
    public static <T> T[] copyOf(T[] original) {
        return (T[]) copyOf(original, original.length);
    }
}

Related

  1. copy(double[] dataToCopy)
  2. copyArrayGrow1(Object array, Class newArrayComponentType)
  3. copyOf(Object src)
  4. copyOf(String[] obj)
  5. copyOf(String[] obj, int newSize)
  6. copyOf(T[] original, int newLength)
  7. copyOf(T[] source, T[] result)
  8. copyOf(boolean[] obj)
  9. copyOf(boolean[] obj, int newSize)