public int[] merge(int[] a, int[] b) { int[] c = new int[a.length + b.length]; int i = 0, j = 0, la = a.length, lb = b.length; int p = 0; while (i < la && j < lb) { if (a[i] < b[j]) { c[p++] = a[i]; i++; } else { c[p++] = b[j]; j++; } } while (i < la) { c[p++] = a[i]; i++; } while (j < lb) { c[p++] = b[j]; j++; } return c; }