int capacityIncrement = 0;
int capacity = 0;
double [] myArray = {1, 2, 3, 4, 5};

if (capacityIncrement == 0) {
  capacity *= 2;
}
else {
  capacity += capacityIncrement;
}
// now create a new array using the updated 
// capacity value
double [] newArray = new double[capacity];
// copy the contents of the original array
// to the new array
for (int i = 0; i < myArray.length; i++) {
  newArray[i] = myArray[i];
} // end for
// now change the reference to the original array
// to the new array
myArray = newArray;

