Java Array Range Copy copyOf(Object[] array, int newLength)

Here you can find the source of copyOf(Object[] array, int newLength)

Description

copy Of

License

Open Source License

Declaration

public static Object[] copyOf(Object[] array, int newLength) 

Method Source Code

//package com.java2s;
/*/*  ww  w.  j av a2 s  .  c  o  m*/
 * Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved. This
 * code is released under a tri EPL/GPL/LGPL license. You can use it,
 * redistribute it and/or modify it under the terms of the:
 *
 * Eclipse Public License version 1.0
 * GNU General Public License version 2
 * GNU Lesser General Public License version 2.1
 */

public class Main {
    public static Object[] copyOf(Object[] array, int newLength) {
        final Object[] copy = new Object[newLength];
        System.arraycopy(array, 0, copy, 0, Math.min(array.length, newLength));
        return copy;
    }

    public static void arraycopy(Object[] src, int srcPos, Object[] dest, int destPos, int length) {
        System.arraycopy(src, srcPos, dest, destPos, length);
    }
}

Related

  1. copyOf(int[] source, int length)
  2. copyOf(int[] src, int size)
  3. copyOf(int[][] pixels)
  4. copyOf(Integer[] original)
  5. copyOf(Object src, int newLength)
  6. copyOf(Object[] values, int nlen)
  7. copyOf(String[] data, int newLength)
  8. copyOf(String[] original, int newLength)
  9. copyOf(T[] oriArray, int newArraySize, int startOffset)