Java Array Range Copy copyOf(int[] arr, int length)

Here you can find the source of copyOf(int[] arr, int length)

Description

copy Of

License

Open Source License

Declaration

public static int[] copyOf(int[] arr, int length) 

Method Source Code

//package com.java2s;
// it under the terms of the GNU General Public License as published by      //

public class Main {
    public static int[] copyOf(int[] arr, int length) {
        int[] copy = new int[arr.length];
        System.arraycopy(arr, 0, copy, 0, length);
        return copy;
    }/*www.  ja va  2s. c  om*/

    public static double[][] copyOf(double[][] arr) {
        double[][] copy = new double[arr.length][arr[0].length];

        for (int i = 0; i < arr.length; i++) {
            System.arraycopy(arr[i], 0, copy[i], 0, arr[0].length);
        }

        return copy;
    }
}

Related

  1. copyOf(char[] source)
  2. copyOf(double[] array, int length)
  3. copyOf(double[] v, int newlength)
  4. copyOf(final byte[] bytes)
  5. copyOf(int[] arr)
  6. copyOf(int[] old, int length)
  7. copyOf(int[] source, int length)
  8. copyOf(int[] src, int size)
  9. copyOf(int[][] pixels)