code: public double[] createDoubleArray(Double[] doubles) {
          double[] result;
          if (doubles != null) {
              int count = 0;
              int inputLength = doubles.length;
              double[] tempResult = new double[inputLength];
              for (int i = 0; i < inputLength; i++) {
                  if (doubles[i] != null) {
                      tempResult[count] = doubles[i].doubleValue();
                      count++;
                  }
              }
              result = tempResult;
              if (count != inputLength) {
                  result = new double[count];
                  System.arraycopy(tempResult, 0, result, 0, count);
              }
          } else {
              result = null;
          }
  
          return result;
      }
docs: Create an array of <code>double</code> values from the given array of
  {@link Double} values. Each value in the given array will be unwrapped to
  its primitive form. If any values within the given array are
  <code>null</code>, then they will be ignored and the resulting array will
  be smaller than the given array.
  
  @param doubles The array of doubles to convert
  
  @return The array of primitive doubles