Java Array Range Copy copyOf(int[] src, int size)

Here you can find the source of copyOf(int[] src, int size)

Description

copy Of

License

Open Source License

Declaration

public static int[] copyOf(int[] src, int size) 

Method Source Code

//package com.java2s;

public class Main {
    public static int[] copyOf(int[] src, int size) {
        int[] dst = new int[size];
        System.arraycopy(src, 0, dst, 0, Math.min(src.length, size));
        return dst;
    }/*w w w  .  j a  v a2s .co  m*/

    public static long[] copyOf(long[] src, int size) {
        long[] dst = new long[size];
        System.arraycopy(src, 0, dst, 0, Math.min(src.length, size));
        return dst;
    }

    public static Object[] copyOf(Object[] src, int size) {
        Object[] dst = new Object[size];
        System.arraycopy(src, 0, dst, 0, Math.min(src.length, size));
        return dst;
    }
}

Related

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