Java Array Merge mergeStringArray(String[] ary1, String[] ary2)

Here you can find the source of mergeStringArray(String[] ary1, String[] ary2)

Description

merge String Array

License

Apache License

Declaration

public static String[] mergeStringArray(String[] ary1, String[] ary2) 

Method Source Code

//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;
    }
}

Related

  1. mergeSort(Object[] src, Object[] dest, int low, int high, int off, Comparator c)
  2. mergeSortArrays(String[][] arrayArray)
  3. mergeSortedInc(long[] a, long[] b)
  4. mergeStringArray(String[] array)
  5. mergeStringArray(String[] array, String seperator)
  6. mergeStringArray(String[] inp1, String[] inp2)
  7. mergeStringArray(String[] input)
  8. mergeStringArrayFromIndex(String[] arrayString, int i)
  9. mergeStringArrays(String array1[], String array2[])