@SafeVarargs public static <T>T[] join(IntFunction<T[]> arrayFunction,T[]... arrays){
  if (arrays.length == 0) {
    return arrayFunction.apply(0);
  }
  if (arrays.length == 1) {
    return arrays[0];
  }
  if (arrays.length == 2) {
    return join(arrayFunction,arrays[0],arrays[1]);
  }
  T[] notNull=null;
  int finalSize=0;
  int nullArrays=0;
  List<T> list=new ArrayList<>(arrays.length * 10);
  for (  T[] array : arrays) {
    if ((array == null) || (array.length == 0)) {
      nullArrays++;
    }
 else {
      notNull=array;
      finalSize+=array.length;
      Collections.addAll(list,array);
    }
  }
  if (nullArrays == arrays.length) {
    return arrayFunction.apply(0);
  }
  if (nullArrays == (arrays.length - 1)) {
    return notNull;
  }
  return list.toArray(arrayFunction.apply(list.size()));
}

@ SafeVarargs public static < T > T [ ] join ( IntFunction < T [ ] > arrayFunction , T [ ] ... arrays ) { if ( arrays . length == 0 ) { return arrayFunction . apply ( 0 ) ; } if ( arrays . length == 1 ) { return arrays [ 0 ] ; } if ( arrays . length == 2 ) { return join ( arrayFunction , arrays [ 0 ] , arrays [ 1 ] ) ; } T [ ] notNull = null ; int finalSize = 0 ; int nullArrays = 0 ; List < T > list = new ArrayList < > ( arrays . length * 10 ) ; for ( T [ ] array : arrays ) { if ( ( array == null ) || ( array . length == 0 ) ) { nullArrays ++ ; } else { notNull = array ; finalSize += array . length ; Collections . addAll ( list , array ) ; } } if ( nullArrays == arrays . length ) { return arrayFunction . apply ( 0 ) ; } if ( nullArrays == ( arrays . length - 1 ) ) { return notNull ; } return list . toArray ( arrayFunction . apply ( list . size ( ) ) ) ; }
joins arrays together , if only one array contains elements it will be returned without coping anything . < br > if given array or arrays is empty , new empty array will be returned .
