Java - Write code to parse Double from string and catch exception

Requirements

Write code to parse Double from string and catch exception

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String value = "book2s.com";
        System.out.println(getDouble(value));
    }//w w  w. j  a va 2  s  . c om

    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);
    }
}