Here you can find the source of mergeByArray(int[] a, int[] b)
private static int[] mergeByArray(int[] a, int[] b)
//package com.java2s; //License from project: Apache License public class Main { private static int[] mergeByArray(int[] a, int[] b) { int[] c = new int[a.length + b.length]; int i = 0, j = 0, k = 0; while (i < a.length && j < b.length) { if (a[i] <= b[j]) { if (a[i] == b[j]) { j++;/*from w w w.ja va 2 s .c om*/ } else { c[k] = a[i]; i++; k++; } } else { c[k] = b[j]; j++; k++; } } while (i < a.length) { c[k] = a[i]; k++; i++; } while (j < b.length) { c[k] = b[j]; j++; k++; } return c; } }