Here you can find the source of merge(int[] a, int[] b)
public static int[] merge(int[] a, int[] b)
//package com.java2s; //License from project: Open Source License public class Main { public static int[] merge(int[] a, int[] b) { int[] c = new int[a.length + b.length]; int p = 0, q = 0; while (p < a.length && q < b.length) { if (a[p] < b[q]) c[p + q] = a[p++];/* w ww. ja v a 2s . c o m*/ else c[p + q] = b[q++]; } while (p < a.length) c[p + q] = a[p++]; while (q < b.length) c[p + q] = b[q++]; return c; } }