public static double[] concatenate(double[]... x){
  int combinedLength=0;
  for (  double[] a : x) {
    combinedLength+=a.length;
  }
  int offset=0;
  int curLength=0;
  final double[] combined=new double[combinedLength];
  for (int i=0; i < x.length; i++) {
    curLength=x[i].length;
    System.arraycopy(x[i],0,combined,offset,curLength);
    offset+=curLength;
  }
  return combined;
}

public static double [ ] concatenate ( double [ ] ... x ) { int combinedLength = 0 ; for ( double [ ] a : x ) { combinedLength += a . length ; } int offset = 0 ; int curLength = 0 ; final double [ ] combined = new double [ combinedLength ] ; for ( int i = 0 ; i < x . length ; i ++ ) { curLength = x [ i ] . length ; System . arraycopy ( x [ i ] , 0 , combined , offset , curLength ) ; offset += curLength ; } return combined ; }
concatenates a sequence of arrays . the return array consists of the entries of the input arrays concatenated in the order they appear in the argument list . null arrays cause nullpointerexceptions ; zero length arrays are allowed ( contributing nothing to the output array ) .
