Java Array Merge merge(E[] arrayA, E[] arrayB)

Here you can find the source of merge(E[] arrayA, E[] arrayB)

Description

Merges the two arrays passed in argument into a single one, in the order specified.

License

Open Source License

Parameter

Parameter Description
arrayA the first array
arrayB the second array

Return

new array

Declaration

public static <E> E[] merge(E[] arrayA, E[] arrayB) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Arrays;

public class Main {
    /**//from  www  .j  a v  a  2  s  . co  m
     * Merges the two arrays passed in argument into a single one,
     * in the order specified.
     * 
     * @param arrayA
     *            the first array
     * @param arrayB
     *            the second array
     * @return new array
     */
    public static <E> E[] merge(E[] arrayA, E[] arrayB) {
        E[] result = Arrays.copyOf(arrayA, arrayA.length + arrayB.length);
        System.arraycopy(arrayB, 0, result, arrayA.length, arrayB.length);
        return result;
    }
}

Related

  1. merge(byte[]... arrays)
  2. merge(byte[]... bytes)
  3. merge(double[] a, int[] b, int p, int q, int r)
  4. merge(double[]... args)
  5. merge(E[] a1, E[] a2)
  6. merge(final byte[] b1, final byte[] b2)
  7. merge(final byte[]... data)
  8. merge(final String[] array1, final String[] array2)
  9. merge(final T[] array1, final T[] array2)