Here you can find the source of concatArrays(T[] first, T[] second)
Parameter | Description |
---|---|
first | the first array |
second | the second array |
public static <T> T[] concatArrays(T[] first, T[] second)
//package com.java2s; /******************************************************************************* * Copyright (C) 2012 Constantine Lignos * //from w w w .j a v a2 s. c om * This file is a part of MORSEL. * * MORSEL is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * MORSEL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MORSEL. If not, see <http://www.gnu.org/licenses/>. ******************************************************************************/ import java.util.Arrays; public class Main { /** * Concatenate two arrays of the same type. * @param first the first array * @param second the second array * @return a new array containing the elements of the first and second arrays in order */ public static <T> T[] concatArrays(T[] first, T[] second) { T[] result = Arrays.copyOf(first, first.length + second.length); System.arraycopy(second, 0, result, first.length, second.length); return result; } }