Here you can find the source of arrayConcat(T[] first, T[] second)
Parameter | Description |
---|---|
first | First array |
second | Second array |
public static <T> T[] arrayConcat(T[] first, T[] second)
//package com.java2s; /******************************************************************************* * Copyright (c) 2011, 2012 Alex Bradley. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from w w w . j av a 2s . c o m * Alex Bradley - initial API and implementation *******************************************************************************/ import java.util.Arrays; public class Main { /** * Concatenate two arrays. * @param first First array * @param second Second array * @return Array of length {@code (first.length + second.length)} consisting of the elements of {@code first} * followed by the elements of {@code second}. */ public static <T> T[] arrayConcat(T[] first, T[] second) { T[] result = Arrays.copyOf(first, first.length + second.length); System.arraycopy(second, 0, result, first.length, second.length); return result; } }