Java Array Merge mergeCharArrays(char[] array1, char[] array2)

Here you can find the source of mergeCharArrays(char[] array1, char[] array2)

Description

Simple method to merge two character arrays.

License

Apache License

Parameter

Parameter Description
array1 a character array
array2 a character array

Return

a concatenation of array1 and array2

Declaration

public static char[] mergeCharArrays(char[] array1, char[] array2) 

Method Source Code

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

public class Main {
    /**/*ww  w. j  av a 2  s.c o m*/
     * Simple method to merge two character arrays.
     * 
     * @param array1 a character array
     * @param array2 a character array
     * 
     * @return a concatenation of array1 and array2
     */
    public static char[] mergeCharArrays(char[] array1, char[] array2) {
        char[] result = new char[array1.length + array2.length];
        int count = 0;
        for (int i = 0; i < array1.length; i++) {
            result[count] = array1[i];
            count++;
        }
        for (int i = 0; i < array2.length; i++) {
            result[count] = array2[i];
            count++;
        }
        return result;
    }
}

Related

  1. mergeByArray(int[] a, int[] b)
  2. mergeByteArraies(byte[] array1, byte[] array2)
  3. mergeByteArrays(byte[] array1, byte[] array2)
  4. mergeByteArrays(byte[] one, byte[] two)
  5. mergeBytearrays(byte[] ret, byte[] header, byte[] body)
  6. mergeColumnsSafely(int[] arrOriginalColumns, int[] arrExtraColumns)
  7. mergeNoDuplicates(String[] in1, String[] in2)
  8. mergeParameterVariableNameDescription(String[] parameterType, String[] variableName)
  9. mergerBy(String[] target, String seperator)