code: private static double[] adjustSize (double[] array, int newSize) {
          if (newSize <= array.length) {
              return array;
          }
          double[] newArray = new double[2 * newSize];
          System.arraycopy(array, 0, newArray, 0, array.length);
          return newArray;
      }
docs: the method check up the array size and necessarily increases it.