![]() |
VOOZH | about |
In this article, we will convert a String to a Double in Java. There are three methods for this conversion from String to Double, as mentioned below in the article.
Different ways for converting a String to a Double are mentioned below:
The parseDouble() method of the Java Double class is a built-in method in Java that returns a new double initialized to the value represented by the specified String, as done by the valueOf method of class Double.
Syntax:
double d = Double.parseDouble(str);
Example: Java Program to Convert String to Double Using parseDouble() Method.
2033.12244
The doubleValue() method of Double class is a built-in method to return the value specified by the calling object as double after type casting.
Syntax:
double d = Double.valueOf(str);
Example: Java Program to Convert String to Double Using valueOf() Method.
2033.12244
The Double class contains the constructor to intialize the Double objects using a String object.
Syntax:
Double d = new Double(str);
Example: Java Program to Convert String to Double Using Double Class Constructor.
2033.12244