Here you can find the source of copyArray(T[] array)
Parameter | Description |
---|---|
array | The array to copy |
public static <T> T[] copyArray(T[] array)
//package com.java2s; // License: GPL. For details, see LICENSE file. import java.util.Arrays; public class Main { /**/*from w w w. j a v a 2 s . com*/ * Copies the given array. Unlike {@link Arrays#copyOf}, this method is null-safe. * @param array The array to copy * @return A copy of the original array, or {@code null} if {@code array} is null * @since 6221 */ public static <T> T[] copyArray(T[] array) { if (array != null) { return Arrays.copyOf(array, array.length); } return null; } /** * Copies the given array. Unlike {@link Arrays#copyOf}, this method is null-safe. * @param array The array to copy * @return A copy of the original array, or {@code null} if {@code array} is null * @since 6222 */ public static char[] copyArray(char[] array) { if (array != null) { return Arrays.copyOf(array, array.length); } return null; } }