Here you can find the source of concatenateArray(Object[] srcOne, Object[] srcTwo)
Parameter | Description |
---|---|
srcOne | array to concatenate |
srcTwo | array to concatenate |
public static Object[] concatenateArray(Object[] srcOne, Object[] srcTwo)
//package com.java2s; /*// w w w . j a v a 2 s. c om * ************************************************************************************* * Copyright (C) 2008 EsperTech, Inc. All rights reserved. * * http://esper.codehaus.org * * http://www.espertech.com * * ---------------------------------------------------------------------------------- * * The software in this package is published under the terms of the GPL license * * a copy of which has been included with this distribution in the license.txt file. * * ************************************************************************************* */ import java.util.*; public class Main { /** * Concatenate two arrays. * @param srcOne array to concatenate * @param srcTwo array to concatenate * @return concatenated array */ public static Object[] concatenateArray(Object[] srcOne, Object[] srcTwo) { Object[] result = new Object[srcOne.length + srcTwo.length]; System.arraycopy(srcOne, 0, result, 0, srcOne.length); System.arraycopy(srcTwo, 0, result, srcOne.length, srcTwo.length); return result; } /** * Concatenate multiple arrays. * @param more arrays to concatenate * @return concatenated array */ public static Object[] concatenateArray(Object[]... more) { List list = new ArrayList(); for (int i = 0; i < more.length; i++) { for (int j = 0; j < more[i].length; j++) { list.add(more[i][j]); } } return list.toArray(); } }