Java Array Range Copy copyOf(double[] v, int newlength)

Here you can find the source of copyOf(double[] v, int newlength)

Description

copy Of

License

Open Source License

Declaration

public static double[] copyOf(double[] v, int newlength) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static double[] copyOf(double[] v, int newlength) {
        double[] ret = new double[newlength];
        System.arraycopy(v, 0, ret, 0, Math.min(newlength, v.length));
        return ret;
    }//from   w  ww  . ja va  2s.  c o m

    public static int[] copyOf(int[] v, int newlength) {
        int[] ret = new int[newlength];
        System.arraycopy(v, 0, ret, 0, Math.min(newlength, v.length));
        return ret;
    }

    public static byte[] copyOf(byte[] v, int newlength) {
        byte[] ret = new byte[newlength];
        System.arraycopy(v, 0, ret, 0, Math.min(newlength, v.length));
        return ret;
    }

    public static float[] copyOf(float[] v, int newlength) {
        float[] ret = new float[newlength];
        System.arraycopy(v, 0, ret, 0, Math.min(newlength, v.length));
        return ret;
    }
}

Related

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