Java Utililty Methods Array Merge

List of utility methods to do Array Merge

Description

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

Method

long[]mergeSortedInc(long[] a, long[] b)
merge Sorted Inc
assert isSortedInc(a) && isSortedInc(b);
long[] res = new long[a.length + b.length];
int ai = 0, bi = 0;
while (ai < a.length || bi < b.length) {
    if (a[ai] < b[bi]) {
        res[ai + bi] = a[ai];
        ai++;
    } else if (b[bi] < a[ai]) {
...
StringmergeStringArray(String[] array)
merge String Array
return splitStringArray(array, 0);
StringBuildermergeStringArray(String[] array, String seperator)
merge String Array
StringBuilder output = new StringBuilder("");
if (array != null && array.length > 0) {
    output.append(array[0]);
    for (int i = 1; i < array.length; i++) {
        output.append(seperator).append(array[i]);
return output;
...
String[]mergeStringArray(String[] ary1, String[] ary2)
merge String Array
if (null == ary1)
    return ary2;
if (null == ary2)
    return ary1;
List<String> l1 = new ArrayList<String>(Arrays.asList(ary1));
List<String> l2 = Arrays.asList(ary2);
for (String s : l2) {
    if (!l1.contains(s)) {
...
String[]mergeStringArray(String[] inp1, String[] inp2)
merge String Array
String[] ret = new String[inp1.length + inp2.length];
System.arraycopy(inp1, 0, ret, 0, inp1.length);
System.arraycopy(inp2, 0, ret, inp1.length, inp2.length);
return ret;
StringmergeStringArray(String[] input)
merge String Array
String merged = "";
for (int i = 0; i < input.length; i++) {
    merged += input[i];
return merged;
StringmergeStringArrayFromIndex(String[] arrayString, int i)
merge String Array From Index
StringBuilder sb = new StringBuilder();
for (; i < arrayString.length; i++) {
    sb.append(arrayString[i]);
    sb.append(' ');
if (sb.length() != 0) {
    sb.deleteCharAt(sb.length() - 1);
return sb.toString();
String[]mergeStringArrays(String array1[], String array2[])
This String utility or util method can be used to merge 2 arrays of string values.
if (array1 == null || array1.length == 0)
    return array2;
if (array2 == null || array2.length == 0)
    return array1;
List<String> array1List = Arrays.asList(array1);
List<String> array2List = Arrays.asList(array2);
List<String> result = new ArrayList<String>(array1List);
List<String> tmp = new ArrayList<String>(array1List);
...
String[]mergeStringArrays(String array1[], String array2[], String array3[])
Merge three string arrays
return mergeStringArrays(mergeStringArrays(array1, array2), array3);
String[]mergeStringArrays(String[] array1, String[] array2)
Merge the given String arrays into one, with overlapping array elements only included once.
if (isObjectEmpty(array1)) {
    return array2;
if (isObjectEmpty(array2)) {
    return array1;
List<String> result = new ArrayList<String>();
result.addAll(Arrays.asList(array1));
...