Java Array Copy copy(int[] array)

Here you can find the source of copy(int[] array)

Description

Copies the given array into a new one.

License

Apache License

Declaration

public static int[] copy(int[] array) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Arrays;

public class Main {
    /**/*www  . j a v a2s . c  om*/
     * Copies the given array into a new one.
     */
    public static int[] copy(int[] array) {
        int[] newInt = new int[array.length];
        System.arraycopy(array, 0, newInt, 0, array.length);
        return newInt;
    }

    /**
     * Copies the given array into a new one.
     */
    public static double[] copy(double[] array) {
        double[] newInt = new double[array.length];
        System.arraycopy(array, 0, newInt, 0, array.length);
        return newInt;
    }

    /**
     * Copies the given array into a new one.
     */
    public static long[] copy(long[] array) {
        long[] newInt = new long[array.length];
        System.arraycopy(array, 0, newInt, 0, array.length);
        return newInt;
    }

    /**
     * Copies the given array into a new one.
     */
    public static <T> T[] copy(T[] array) {
        return Arrays.copyOf(array, array.length);
    }
}

Related

  1. copy(byte[] data, int from)
  2. copy(double[][] a)
  3. copy(final boolean[] array)
  4. copy(final byte[] bytes)
  5. copy(final byte[] inBytes)
  6. copy(int[] array)
  7. copy(int[][] input)
  8. copy(long[] array)
  9. copy(long[] v)