Java Array Append appendArrays(byte[] in1, byte[] in2)

Here you can find the source of appendArrays(byte[] in1, byte[] in2)

Description

append two arrays

License

Apache License

Parameter

Parameter Description
in1 non-null array
in2 non-null array

Return

array of members oa 1 then members of 2

Declaration

public static byte[] appendArrays(byte[] in1, byte[] in2) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**// w  w w . j  a  v  a2  s .  c  om
     * append two arrays
     * @param in1 non-null array
    * @param in2  non-null array
    * @return  array of members oa 1 then members of 2
    */
    public static byte[] appendArrays(byte[] in1, byte[] in2) {
        byte[] ret = new byte[in1.length + in2.length];
        System.arraycopy(in1, 0, ret, 0, in1.length);
        System.arraycopy(in2, 0, ret, in1.length, in2.length);
        return ret;
    }

    /**
     * append two arrays
     * @param in1 non-null array
    * @param in2  non-null array
    * @return  array of members oa 1 then members of 2
    */
    public static int[] appendArrays(int[] in1, int[] in2) {
        int[] ret = new int[in1.length + in2.length];
        System.arraycopy(in1, 0, ret, 0, in1.length);
        System.arraycopy(in2, 0, ret, in1.length, in2.length);
        return ret;
    }

    /**
      * append two arrays
      * @param in1 non-null array
     * @param in2  non-null array
     * @return  array of members oa 1 then members of 2
     */
    public static char[] appendArrays(char[] in1, char[] in2) {
        char[] ret = new char[in1.length + in2.length];
        System.arraycopy(in1, 0, ret, 0, in1.length);
        System.arraycopy(in2, 0, ret, in1.length, in2.length);
        return ret;
    }

    /**
      * append two arrays
      * @param in1 non-null array
     * @param in2  non-null array
     * @return  array of members oa 1 then members of 2
     */
    public static double[] appendArrays(double[] in1, double[] in2) {
        double[] ret = new double[in1.length + in2.length];
        System.arraycopy(in1, 0, ret, 0, in1.length);
        System.arraycopy(in2, 0, ret, in1.length, in2.length);
        return ret;
    }
}

Related

  1. appendArray(Object[] array1, Object[] array2)
  2. appendArray(String[] A, String... B)
  3. appendArray(StringBuilder bld, Object[] array, String sep)
  4. appendArray(StringBuilder sb, int[] arr)
  5. appendArray(StringBuilder sb, T[] array, String delimiter)
  6. appendArrays(final byte[] firstArray, final byte[] secondArray)
  7. ARRAY_AddValueToArray(int new_value, int[] array)
  8. arrayAppend(byte[] original, byte[] append)