Here you can find the source of arrayConcat(T[] first, T[] second)
Parameter | Description |
---|---|
T | a parameter |
first | An array of type T with arbitrary length |
second | An array of type T with arbitrary length |
public static <T> T[] arrayConcat(T[] first, T[] second)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; public class Main { /**//from w w w. j av a 2 s. c om * Concatenate two arrays of type T and produce a new of the same type. The first array is * inserted first followed by the second. * * @param <T> * @param first * An array of type T with arbitrary length * @param second * An array of type T with arbitrary length * @return An array of T, resulted from the concatenation of the given two arrays */ public static <T> T[] arrayConcat(T[] first, T[] second) { T[] combinedArray = Arrays.copyOf(first, first.length + second.length); System.arraycopy(second, 0, combinedArray, first.length, second.length); return combinedArray; } }