Here you can find the source of toDoubles(Double[] values)
public static double[] toDoubles(Double[] values)
//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; } }