Java - Write code to check if a string is Numeric using Double.parseDouble

Requirements

Write code to check if a string is Numeric using Double.parseDouble

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String str = "book2s.com";
        System.out.println(isNumeric(str));
    }//from  w  w  w  .j ava2  s  .c  o  m

    public static boolean isNumeric(String str) {
        try {
            double d = Double.parseDouble(str);
        } catch (NumberFormatException nfe) {
            return false;
        }
        return true;
    }
}