Java Utililty Methods Array Join

List of utility methods to do Array Join

Description

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

Method

T[]join(T[] a, T[] b)
join two arrays together
T[] x = Arrays.copyOf(a, a.length + b.length);
for (int n = 0; n < b.length; n++) {
    x[a.length + n] = b[n];
return x;
T[]join(T[] arr1, T[] arr2)
join
if (arr1 == null || arr1.length == 0) {
    return arr2;
if (arr2 == null || arr2.length == 0) {
    return arr1;
T[] newArrays = (T[]) Arrays.copyOf(arr1, arr1.length + arr2.length, arr1.getClass());
System.arraycopy(arr2, 0, newArrays, arr1.length, arr2.length);
...
Stringjoin(T[] array, String join)
join
return join(array, join, array.length);
Stringjoin(T[] array, String separator)
Join an array of items.
StringBuffer result = new StringBuffer();
for (int i = 0; i < array.length; ++i) {
    if (i != 0)
        result.append(separator);
    result.append(array[i]);
return result.toString();
Stringjoin(T[] array, String separator)

A helper method to form a string using the values inside the array.

return join(Arrays.asList(array), separator);
Stringjoin(T[] array, String separator)
Creates a String of all elements of an array, separated by a separator.
return join(Arrays.asList(array), separator);
Stringjoin(T[] array, String separator)
join
return join(Arrays.asList(array), separator);
Stringjoin(T[] array, String separator)
join
StringBuilder builder = new StringBuilder();
for (int i = 0; i < array.length; i++) {
    builder.append(array[i]);
    if (i < array.length - 1) {
        builder.append(separator);
return builder.toString();
...
T[]join(T[] array1, T[] array2)
Join two arrays.
ArrayList<T> newArray = new ArrayList<T>();
newArray.addAll(Arrays.asList(array1));
newArray.addAll(Arrays.asList(array2));
return newArray.toArray(Arrays.copyOf(array1, 0));
T[]join(T[] first, T[] second)
join
if (first == null)
    return second;
if (second == null)
    return first;
T[] result = Arrays.copyOf(first, first.length + second.length);
System.arraycopy(second, 0, result, first.length, second.length);
return result;