Here you can find the source of merge(int[] array, int i, int mid, int max)
public static void merge(int[] array, int i, int mid, int max)
//package com.java2s; //License from project: Open Source License public class Main { public static void merge(int[] array, int i, int mid, int max) { int[] tmp = new int[max - i + 1]; int k = 0; int left = i; int right = mid + 1; while ((left <= mid) && (right <= max)) { if (array[left] <= array[right]) tmp[k++] = array[left++]; else/*from w w w .j a v a2 s . co m*/ tmp[k++] = array[right++]; } while (left <= mid) { tmp[k++] = array[left++]; } while (right <= max) { tmp[k++] = array[right++]; } for (int j = 0; j < tmp.length; j++) array[i + j] = tmp[j]; } }