Here you can find the source of combineArrays(final Object[] array1, final Object[] array2, final Object[] targetArray)
Parameter | Description |
---|---|
array1 | the first array to copy |
array2 | the second array to copy |
targetArray | the array to copy the two other array into; the type of this array must be suitable to accept elements from both array; the length of this array must be equal or greater than <code>array1.length + array2.length</code> |
public static void combineArrays(final Object[] array1, final Object[] array2, final Object[] targetArray)
//package com.java2s; //License from project: Open Source License public class Main { /**//from www . ja v a 2 s .com * Combines two array into a target array, inserting all elements of the * first array and then all elements of the second array in the target * array. * * @param array1 the first array to copy * @param array2 the second array to copy * @param targetArray the array to copy the two other array into; the * type of this array must be suitable to accept elements from both array; * the length of this array must be equal or greater than * <code>array1.length + array2.length</code> */ public static void combineArrays(final Object[] array1, final Object[] array2, final Object[] targetArray) { final int lengthOfFirst = array1.length; int i; // copy first array into target array for (i = 0; i < lengthOfFirst; i++) { targetArray[i] = array1[i]; } // copy second array into target array for (i = 0; i < array2.length; i++) { targetArray[i + lengthOfFirst] = array2[i]; } } }