Java - Write code to Make the verdict string specified is whether the numerical value.

Requirements

Write code to Make the verdict string specified is whether the numerical value.

Return true if the string is a number, false otherwise

Hint

Use Double.parseDouble method()

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String value = "book2s.com";
        System.out.println(isNumber(value));
    }//from  w  w  w.  ja  va 2s.com

    /**
     * Make the verdict string specified is whether the numerical value.<br/>
     * 
     * @param value
     *            The target string
     * @return If the specified string is a number, and return the {@code true}
     */
    public static boolean isNumber(final String value) {
        try {
            Double.parseDouble(value);
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    }
}