public static double[] copyOf(double[] original,int newLength){
  double[] copy=new double[newLength];
  System.arraycopy(original,0,copy,0,Math.min(original.length,newLength));
  return copy;
}

public static double [ ] copyOf ( double [ ] original , int newLength ) { double [ ] copy = new double [ newLength ] ; System . arraycopy ( original , 0 , copy , 0 , Math . min ( original . length , newLength ) ) ; return copy ; }
java5 ' backport ' of arrays . copyof
