Here you can find the source of merge(T[] array1, T[] array2)
Parameter | Description |
---|---|
T | the generic type |
array1 | the first array |
array2 | the second array |
public static <T> T[] merge(T[] array1, T[] array2)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; public class Main { /**/*from www . j a va2s . c om*/ * Merge two array in a single one. * * @param <T> * the generic type * @param array1 * the first array * @param array2 * the second array * @return an array containing all elements from {@code array1} and {@code array2} (the first element is the first * element of {@code array1}) */ public static <T> T[] merge(T[] array1, T[] array2) { T[] merge = Arrays.copyOf(array1, array1.length + array2.length); for (int i = 0; i < array2.length; i++) { merge[i + array1.length] = array2[i]; } return merge; } }