private double[] extend(double[] array,double value){
  double[] result=null;
  if (array == null) {
    result=new double[1];
  }
 else {
    result=Arrays.copyOf(array,array.length + 1);
  }
  result[result.length - 1]=value;
  return result;
}

private double [ ] extend ( double [ ] array , double value ) { double [ ] result = null ; if ( array == null ) { result = new double [ 1 ] ; } else { result = Arrays . copyOf ( array , array . length + 1 ) ; } result [ result . length - 1 ] = value ; return result ; }
extends the given array with a new element appended to the end .
