Here you can find the source of mergeStrings(String[] x, String[] y)
public static String[] mergeStrings(String[] x, String[] y)
//package com.java2s; import java.util.ArrayList; import java.util.List; public class Main { public static String[] mergeStrings(String[] x, String[] y) { if (x == null) return y; if (y == null) return x; List<String> mergedList = new ArrayList<String>(); int xp = 0, yp = 0; while (xp < x.length && yp < y.length) { if (x[xp].compareTo(y[yp]) < 0) { mergedList.add(x[xp++]); } else if (x[xp].compareTo(y[yp]) > 0) { mergedList.add(y[yp++]); } else { mergedList.add(x[xp]);// w w w .java 2s . c om xp++; yp++; } } while (xp < x.length) { mergedList.add(x[xp++]); } while (yp < y.length) { mergedList.add(y[yp++]); } return mergedList.toArray(new String[0]); } }