Last Updated : 11 Jul, 2025
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.
Methods for String-to-Double ConversionDifferent 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.
Java
// Java program to convert String to Double
// Using parseDouble() Method of Double Class
// Main class
public class Geeks
{
// Main driver method
public static void main(String args[])
{
// Create and initializing a string
String str = "2033.12244";
// Converting the above string into Double
// using parseDouble() Method
double str1 = Double.parseDouble(str);
// Printing string as Double type
System.out.println(str1);
}
}
The complexity of the above method
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.
Java
// Java program to convert String to Double
// using valueOf() Method of Double Class
// Main class
public class Geeks
{
// Main driver method
public static void main(String args[])
{
// Creating and initializing a string
String str = "2033.12244";
// Converting the above string to Double type
double d = Double.valueOf(str);
// Printing above string as double type
System.out.println(d);
}
}
The complexity of the above method
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.
Java
// Java program to convert String to Double
// Using Constructor of Double class
// Main class
public class Geeks
{
// Main driver method
public static void main(String args[])
{
// Creating and initializing a string
String str = "2033.12244";
// Converting above string into double type
Double d = new Double(str);
// print above string as Double type
System.out.println(d);
}
}
The complexity of the above method
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4