Java Array Concatenate concat(boolean[] a, boolean[] b)

Here you can find the source of concat(boolean[] a, boolean[] b)

Description

Return an array containing a copy of array a and b

License

Open Source License

Parameter

Parameter Description
a the first array
b the second array

Return

a new array containing a shallow copy of both arrays

Declaration

public static final boolean[] concat(boolean[] a, boolean[] b) 

Method Source Code


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

import java.util.Arrays;

public class Main {
    /** Return an array containing a copy of array {@code a} and {@code b}
     * @param a the first array//from w ww . ja v a  2s . c o  m
     * @param b the second array
     * @return a new array containing a shallow copy of both arrays
     */
    public static final boolean[] concat(boolean[] a, boolean[] b) {
        boolean[] r = Arrays.copyOf(a, a.length + b.length);
        System.arraycopy(b, 0, r, a.length, b.length);
        return r;
    }

    /** Return an array containing a copy of array {@code a} and {@code b}
     * @param a the first array
     * @param b the second array
     * @param dst the destination array to store the copied elements in
     * @param dstOff the offset into {@code dst} at which to append array {@code a} and {@code b}
     * @return a new array containing a shallow copy of both arrays
     */
    public static final boolean[] concat(boolean[] a, boolean[] b, boolean[] dst, int dstOff) {
        System.arraycopy(a, 0, dst, dstOff, a.length);
        System.arraycopy(b, 0, dst, dstOff + a.length, b.length);
        return dst;
    }

    /** Return an array containing a copy of array {@code a} and {@code b}
     * @param a the first array
     * @param b the second array
     * @return a new array containing a shallow copy of both arrays
     */
    public static final byte[] concat(byte[] a, byte[] b) {
        byte[] r = Arrays.copyOf(a, a.length + b.length);
        System.arraycopy(b, 0, r, a.length, b.length);
        return r;
    }

    /** Return an array containing a copy of array {@code a} and {@code b}
     * @param a the first array
     * @param b the second array
     * @param dst the destination array to store the copied elements in
     * @param dstOff the offset into {@code dst} at which to append array {@code a} and {@code b}
     * @return a new array containing a shallow copy of both arrays
     */
    public static final byte[] concat(byte[] a, byte[] b, byte[] dst, int dstOff) {
        System.arraycopy(a, 0, dst, dstOff, a.length);
        System.arraycopy(b, 0, dst, dstOff + a.length, b.length);
        return dst;
    }

    /** Return an array containing a copy of array {@code a} and {@code b}
     * @param a the first array
     * @param b the second array
     * @return a new array containing a shallow copy of both arrays
     */
    public static final short[] concat(short[] a, short[] b) {
        short[] r = Arrays.copyOf(a, a.length + b.length);
        System.arraycopy(b, 0, r, a.length, b.length);
        return r;
    }

    /** Return an array containing a copy of array {@code a} and {@code b}
     * @param a the first array
     * @param b the second array
     * @param dst the destination array to store the copied elements in
     * @param dstOff the offset into {@code dst} at which to append array {@code a} and {@code b}
     * @return a new array containing a shallow copy of both arrays
     */
    public static final short[] concat(short[] a, short[] b, short[] dst, int dstOff) {
        System.arraycopy(a, 0, dst, dstOff, a.length);
        System.arraycopy(b, 0, dst, dstOff + a.length, b.length);
        return dst;
    }

    /** Return an array containing a copy of array {@code a} and {@code b}
     * @param a the first array
     * @param b the second array
     * @return a new array containing a shallow copy of both arrays
     */
    public static final char[] concat(char[] a, char[] b) {
        char[] r = Arrays.copyOf(a, a.length + b.length);
        System.arraycopy(b, 0, r, a.length, b.length);
        return r;
    }

    /** Return an array containing a copy of array {@code a} and {@code b}
     * @param a the first array
     * @param b the second array
     * @param dst the destination array to store the copied elements in
     * @param dstOff the offset into {@code dst} at which to append array {@code a} and {@code b}
     * @return a new array containing a shallow copy of both arrays
     */
    public static final char[] concat(char[] a, char[] b, char[] dst, int dstOff) {
        System.arraycopy(a, 0, dst, dstOff, a.length);
        System.arraycopy(b, 0, dst, dstOff + a.length, b.length);
        return dst;
    }

    /** Return an array containing a copy of array {@code a} and {@code b}
     * @param a the first array
     * @param b the second array
     * @return a new array containing a shallow copy of both arrays
     */
    public static final int[] concat(int[] a, int[] b) {
        int[] r = Arrays.copyOf(a, a.length + b.length);
        System.arraycopy(b, 0, r, a.length, b.length);
        return r;
    }

    /** Return an array containing a copy of array {@code a} and {@code b}
     * @param a the first array
     * @param b the second array
     * @param dst the destination array to store the copied elements in
     * @param dstOff the offset into {@code dst} at which to append array {@code a} and {@code b}
     * @return a new array containing a shallow copy of both arrays
     */
    public static final int[] concat(int[] a, int[] b, int[] dst, int dstOff) {
        System.arraycopy(a, 0, dst, dstOff, a.length);
        System.arraycopy(b, 0, dst, dstOff + a.length, b.length);
        return dst;
    }

    /** Return an array containing a copy of array {@code a} and {@code b}
     * @param a the first array
     * @param b the second array
     * @return a new array containing a shallow copy of both arrays
     */
    public static final long[] concat(long[] a, long[] b) {
        long[] r = Arrays.copyOf(a, a.length + b.length);
        System.arraycopy(b, 0, r, a.length, b.length);
        return r;
    }

    /** Return an array containing a copy of array {@code a} and {@code b}
     * @param a the first array
     * @param b the second array
     * @param dst the destination array to store the copied elements in
     * @param dstOff the offset into {@code dst} at which to append array {@code a} and {@code b}
     * @return a new array containing a shallow copy of both arrays
     */
    public static final long[] concat(long[] a, long[] b, long[] dst, int dstOff) {
        System.arraycopy(a, 0, dst, dstOff, a.length);
        System.arraycopy(b, 0, dst, dstOff + a.length, b.length);
        return dst;
    }

    /** Return an array containing a copy of array {@code a} and {@code b}
     * @param a the first array
     * @param b the second array
     * @return a new array containing a shallow copy of both arrays
     */
    public static final float[] concat(float[] a, float[] b) {
        float[] r = Arrays.copyOf(a, a.length + b.length);
        System.arraycopy(b, 0, r, a.length, b.length);
        return r;
    }

    /** Return an array containing a copy of array {@code a} and {@code b}
     * @param a the first array
     * @param b the second array
     * @param dst the destination array to store the copied elements in
     * @param dstOff the offset into {@code dst} at which to append array {@code a} and {@code b}
     * @return a new array containing a shallow copy of both arrays
     */
    public static final float[] concat(float[] a, float[] b, float[] dst, int dstOff) {
        System.arraycopy(a, 0, dst, dstOff, a.length);
        System.arraycopy(b, 0, dst, dstOff + a.length, b.length);
        return dst;
    }

    /** Return an array containing a copy of array {@code a} and {@code b}
     * @param a the first array
     * @param b the second array
     * @return a new array containing a shallow copy of both arrays
     */
    public static final double[] concat(double[] a, double[] b) {
        double[] r = Arrays.copyOf(a, a.length + b.length);
        System.arraycopy(b, 0, r, a.length, b.length);
        return r;
    }

    /** Return an array containing a copy of array {@code a} and {@code b}
     * @param a the first array
     * @param b the second array
     * @param dst the destination array to store the copied elements in
     * @param dstOff the offset into {@code dst} at which to append array {@code a} and {@code b}
     * @return a new array containing a shallow copy of both arrays
     */
    public static final double[] concat(double[] a, double[] b, double[] dst, int dstOff) {
        System.arraycopy(a, 0, dst, dstOff, a.length);
        System.arraycopy(b, 0, dst, dstOff + a.length, b.length);
        return dst;
    }

    /** Return an array containing a copy of array {@code a} and {@code b}
     * @param a the first array
     * @param b the second array
     * @return a new array containing a shallow copy of both arrays
     */
    public static final <T> T[] concat(T[] a, T[] b) {
        T[] r = Arrays.copyOf(a, a.length + b.length);
        System.arraycopy(b, 0, r, a.length, b.length);
        return r;
    }

    /** Return an array containing a copy of array {@code a} and {@code b}
     * @param a the first array
     * @param b the second array
     * @param dst the destination array to store the copied elements in
     * @param dstOff the offset into {@code dst} at which to append array {@code a} and {@code b}
     * @return a new array containing a shallow copy of both arrays
     */
    public static final <T> T[] concat(T[] a, T[] b, T[] dst, int dstOff) {
        System.arraycopy(a, 0, dst, dstOff, a.length);
        System.arraycopy(b, 0, dst, dstOff + a.length, b.length);
        return dst;
    }
}

Related

  1. arrayConcat(T[] first, T[] second)
  2. arrayConcat(T[] first, T[] second)
  3. arrayConcatenate(final String[] f, final String[] s)
  4. arrayConcatenate(String[] first, String[] second)
  5. arrayConcatInt(final int[] original, final int[] appender)
  6. concat(boolean[]... arys)
  7. concat(byte[] a, byte[]... b)
  8. concat(byte[] first, byte[] second)
  9. concat(byte[] first, byte[] second)