Here you can find the source of toDouble(String value, double defaultValue)
Parameter | Description |
---|---|
value | a String |
defaultValue | default double value to return if conversion fails |
public static double toDouble(String value, double defaultValue)
//package com.java2s; public class Main { /**/*from w ww . ja v a 2 s . c o m*/ * Returns the given String parsed to a Double. If the String cannot be * converted, the default value will be returned instead. * * @param value a String * @param defaultValue default double value to return if conversion fails * @return double */ public static double toDouble(String value, double defaultValue) { try { return Double.parseDouble(value); } catch (NumberFormatException e) { return defaultValue; } } }