Write code to parse Double from string and catch exception
//package com.book2s; public class Main { public static void main(String[] argv) { String value = "book2s.com"; System.out.println(getDouble(value)); }/*from w w w .j ava2 s . co m*/ public static double getDouble(String value, double defaultValue) { double result = defaultValue; try { result = Double.parseDouble(value); } catch (Exception ex) { } return result; } public static double getDouble(String value) { return getDouble(value, 0.0D); } }