Java Double Number From toDoubles(Double[] values)

Here you can find the source of toDoubles(Double[] values)

Description

to Doubles

License

Open Source License

Declaration

public static double[] toDoubles(Double[] values) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static final double DEFAULT_DOUBLE = 0d;

    public static double[] toDoubles(Double[] values) {
        return toDoubles(values, DEFAULT_DOUBLE);
    }// w ww  . j  a va 2s  .co m

    public static double[] toDoubles(Double[] values, double defaultValue) {
        double[] results = new double[0];
        if (values != null) {
            results = new double[values.length];
            for (int i = 0; i < results.length; i++) {
                Double element = values[i];
                try {
                    results[i] = (element != null ? element.doubleValue()
                            : defaultValue);
                } catch (Exception ex) {
                    // ex.printStackTrace();
                }
            }
        }
        return results;
    }

    public static Double[] toDoubles(double[] values) {
        return toDoubles(values, DEFAULT_DOUBLE);
    }

    public static Double[] toDoubles(double[] values, double defaultValue) {
        Double[] results = new Double[0];
        if (values != null) {
            results = new Double[values.length];
            for (int i = 0; i < results.length; i++) {
                double element = values[i];
                try {
                    results[i] = new Double(element);
                } catch (Exception ex) {
                    results[i] = defaultValue;
                    // ex.printStackTrace();
                }
            }
        }
        return results;
    }
}

Related

  1. toDoublePrecision(long fixedPrecisionOrdinate)
  2. toDoublePrimitiveArray(final Double[] wrappedArray)
  3. toDoubleQuotes(String str)
  4. toDoubles(byte[] bytes)
  5. toDoubles(byte[] value, int offset, int num)
  6. toDoubles(int[][] intPts)
  7. toDoubles(Object[] extraArgs)
  8. toDoubleScore(Float score)
  9. toDoubleString(Double d)