Here you can find the source of mergeStringArray(String[] ary1, String[] ary2)
public static String[] mergeStringArray(String[] ary1, String[] ary2)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Main { public static String[] mergeStringArray(String[] ary1, String[] ary2) { if (null == ary1) return ary2; if (null == ary2) return ary1; List<String> l1 = new ArrayList<String>(Arrays.asList(ary1)); List<String> l2 = Arrays.asList(ary2); for (String s : l2) { if (!l1.contains(s)) { l1.add(s);//from w w w . j a v a2 s. c o m } } String[] strings = new String[l1.size()]; l1.toArray(strings); return strings; } }