Here you can find the source of mergeSortedInc(long[] a, long[] b)
public static final long[] mergeSortedInc(long[] a, long[] b)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.util.Arrays; public class Main { public static final long[] mergeSortedInc(long[] a, long[] b) { 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];//from w w w. j a v a 2s .com ai++; } else if (b[bi] < a[ai]) { res[ai + bi] = b[bi]; bi++; } else throw new IllegalArgumentException(Arrays.toString(a) + "|" + Arrays.toString(b)); } return res; } public static final boolean isSortedInc(long[] arr) { for (int i = 0; i < arr.length; i++) { if (i > 0 && arr[i] <= arr[i - 1]) return false; } return true; } public static final boolean isSortedInc(int[] arr) { for (int i = 0; i < arr.length; i++) { if (i > 0 && arr[i] <= arr[i - 1]) return false; } return true; } }