public static String[] unionArrays(String[] array1,String[] array2){
  if (array1 == null) {
    return array2;
  }
  if (array2 == null) {
    return array1;
  }
  Set<String> set=new LinkedHashSet<>();
  set.addAll(Arrays.asList(array1));
  set.addAll(Arrays.asList(array2));
  return set.toArray(new String[set.size()]);
}

public static String [ ] unionArrays ( String [ ] array1 , String [ ] array2 ) { if ( array1 == null ) { return array2 ; } if ( array2 == null ) { return array1 ; } Set < String > set = new LinkedHashSet < > ( ) ; set . addAll ( Arrays . asList ( array1 ) ) ; set . addAll ( Arrays . asList ( array2 ) ) ; return set . toArray ( new String [ set . size ( ) ] ) ; }
returns a union of 2 arrays , ensuring that each string exists only once .
