Java examples for java.lang:String Parse
Parse Double value from String with default value
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { String value = "java2s.com"; System.out.println(getDouble(value)); }/*from w w w. jav a 2 s. com*/ public static Double getDouble(String value, Double defaultValue) { try { return Double.valueOf(value); } catch (Exception ex) { return defaultValue; } } public static Double getDouble(String value) { return getDouble(value, null); } }