Java Array Merge mergeNoDuplicates(String[] in1, String[] in2)

Here you can find the source of mergeNoDuplicates(String[] in1, String[] in2)

Description

merge No Duplicates

License

Apache License

Declaration

public static String[] mergeNoDuplicates(String[] in1, String[] in2) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.*;

public class Main {
    public static String[] mergeNoDuplicates(String[] in1, String[] in2) {
        Set holder = new HashSet();
        if (in1 != null) {
            for (int i = 0; i < in1.length; i++) {
                holder.add(in1[i]);/*from  w  w  w  .j a  v  a 2 s. c o  m*/
            }
        }
        if (in2 != null) {
            for (int i = 0; i < in2.length; i++) {
                holder.add(in2[i]);
            }
        }
        return (collectionToStringArray(holder));
    }

    /**{ method
     @name collectionToStringArray
     @function return an array of strings from a collection
     @param holder - non-null collection holding strings
     @return  non-null array of strings
     }*/
    public static String[] collectionToStringArray(Collection holder) {
        String[] ret = new String[holder.size()];
        holder.toArray(ret);
        return (ret);
    }
}

Related

  1. mergeByteArrays(byte[] array1, byte[] array2)
  2. mergeByteArrays(byte[] one, byte[] two)
  3. mergeBytearrays(byte[] ret, byte[] header, byte[] body)
  4. mergeCharArrays(char[] array1, char[] array2)
  5. mergeColumnsSafely(int[] arrOriginalColumns, int[] arrExtraColumns)
  6. mergeParameterVariableNameDescription(String[] parameterType, String[] variableName)
  7. mergerBy(String[] target, String seperator)
  8. mergeSort(Object[] src, Object[] dest, int low, int high, int off)
  9. mergeSort(Object[] src, Object[] dest, int low, int high, int off, Comparator c)