Java Array Append appendArray(Object[] array1, Object[] array2)

Here you can find the source of appendArray(Object[] array1, Object[] array2)

Description

Appends array2 to the end of array1 and returns the result

License

Open Source License

Parameter

Parameter Description
array1 a parameter
array2 a parameter

Declaration

public static Object[] appendArray(Object[] array1, Object[] array2) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2000, 2010 IBM Corporation and others.
 * 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 ww  .j a  v a2 s.  c  om*/
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

public class Main {
    /**
     * Appends array2 to the end of array1 and returns the result
     * 
     * @param array1
     * @param array2
     * @return
     */
    public static Object[] appendArray(Object[] array1, Object[] array2) {
        Object[] result = new Object[array1.length + array2.length];
        System.arraycopy(array1, 0, result, 0, array1.length);
        System.arraycopy(array2, 0, result, array1.length, array2.length);
        return result;
    }
}

Related

  1. addToArray(int[] a, int value)
  2. addToArray(String[] items, String str)
  3. appendArray(final byte[] buffer1, final byte[] buffer2)
  4. appendArray(int[][] array, int[] staple)
  5. appendArray(Object[] arr, Object obj)
  6. appendArray(String[] A, String... B)
  7. appendArray(StringBuilder bld, Object[] array, String sep)
  8. appendArray(StringBuilder sb, int[] arr)
  9. appendArray(StringBuilder sb, T[] array, String delimiter)