Android examples for java.lang:array union merge
union two string array
import java.util.LinkedList; public class Main { public static String[] union(String[] a, String[] b) { LinkedList<String> retval = new LinkedList<String>(); for (int i = 0; i < a.length; i++) { retval.add(a[i]);/*from ww w . j av a2 s . c o m*/ } for (int i = 0; i < b.length; i++) { if (!retval.contains(b[i])) { retval.add(b[i]); } } String[] retarray = new String[retval.size()]; retval.toArray(retarray); return retarray; } }