Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find out if the value contained in a string is double or not

Tags:

java

In Java, I am trying to find out if the value contained in a string is double or not?

like image 849
Gauranga Avatar asked Jun 28 '10 15:06

Gauranga


People also ask

How do you check a string is double or not?

Using the parseDouble() method Therefore, to know whether a particular string is parse-able to double or not, pass it to the parseDouble method and wrap this line with try-catch block. If an exception occurs this indicates that the given String is not pars able to double.

How do you know if a variable is double?

PHP : is_double() function The is_double () function is used to test whether a variable is a float or not.


1 Answers

    boolean isDouble(String str) {         try {             Double.parseDouble(str);             return true;         } catch (NumberFormatException e) {             return false;         }     } 
like image 193
unbeli Avatar answered Sep 25 '22 10:09

unbeli