Java Utililty Methods Array Concatenate

List of utility methods to do Array Concatenate

Description

The list of methods to do Array Concatenate are organized into topic(s).

Method

boolean[]concat(boolean[] a, boolean[] b)
Return an array containing a copy of array a and b
boolean[] r = Arrays.copyOf(a, a.length + b.length);
System.arraycopy(b, 0, r, a.length, b.length);
return r;
boolean[]concat(boolean[]... arys)
Return an array containing a copy of all of the input arrays
int totalSize = 0;
for (boolean[] ary : arys) {
    totalSize += ary.length;
boolean[] r = new boolean[totalSize];
int offset = 0;
for (boolean[] ary : arys) {
    System.arraycopy(ary, 0, r, offset, ary.length);
...
byte[]concat(byte[] a, byte[]... b)
Returns two byte arrays concatenated.
int length = a.length;
for (byte[] bytes : b) {
    length += bytes.length;
byte[] result = Arrays.copyOf(a, length);
int pos = a.length;
for (byte[] bytes : b) {
    System.arraycopy(bytes, 0, result, pos, bytes.length);
...
byte[]concat(byte[] first, byte[] second)
concat
if (first == null)
    return second;
if (second == null)
    return first;
byte[] result = Arrays.copyOf(first, first.length + second.length);
System.arraycopy(second, 0, result, first.length, second.length);
return result;
byte[]concat(byte[] first, byte[] second)
concat
if (first == null) {
    if (second == null) {
        return null;
    return second;
if (second == null) {
    return first;
...
byte[]concat(byte[]... arrays)
Returns the concatenation of the given arrays.
return concat(Arrays.asList(arrays));
double[]concat(double[] first, double[] second)
Returns a new array of size first.length + second.length, with the contents of the first array loaded into the returned array starting at the zero'th index, and the contents of the second array appended to the returned array beginning with index first.length.
double[] retVal = Arrays.copyOf(first, first.length + second.length);
for (int i = first.length, j = 0; i < retVal.length; i++, j++) {
    retVal[i] = second[j];
return retVal;
Listconcat(final T[] elements, final T... elementsToAppend)
Creates a mutable list of the provided array, also appending the additional element(s).
final List<T> result = new ArrayList<T>();
for (final T element : elements) {
    result.add(element);
for (final T element : elementsToAppend) {
    if (element != null) {
        result.add(element);
return result;
T[]concat(final T[] first, final T[] second)
Merges two arrays together
if (first == null && second == null)
    return null;
if (first == null)
    return second;
if (second == null)
    return first;
final T[] result = Arrays.copyOf(first, first.length + second.length);
System.arraycopy(second, 0, result, first.length, second.length);
...
float[]concat(float[] A, float[] B)
Concatenates two arrays into one
float[] C = new float[A.length + B.length];
System.arraycopy(A, 0, C, 0, A.length);
System.arraycopy(B, 0, C, A.length, B.length);
return C;