Here you can find the source of merge(T[] left, T... right)
Parameter | Description |
---|---|
T | The array element type. |
left | Array to be merged. |
right | Varargs to be merged with array. |
public static <T> T[] merge(T[] left, T... right)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; public class Main { /**/*from w w w . j a v a 2 s . co m*/ * * @param <T> The array element type. * @param left Array to be merged. * @param right Varargs to be merged with array. * * @return A new array with first all the elements of @left, then all the vararg elements of @right. */ public static <T> T[] merge(T[] left, T... right) { int newLength = left.length + right.length; T[] newArray = Arrays.copyOf(left, newLength); for (int i = left.length; i < newLength; i++) { newArray[i] = right[i - left.length]; } return newArray; } }