Javatpoint Logo
Javatpoint Logo

Java Double parseDouble() Method

The parseDouble method of Java Double class returns a new double value that is initialized to the value corresponding to defined String.

This method executes same as valueOf() method of Float class.



s- This is the string to be parsed.

Return value

The parseDouble() method returns the double value corresponding to the parameter passed.


The parseDouble() method throws:

1.NullPointerException- if the string passed is null.

2.NumberFormatException- if the string passed does not hold a parsable float.

Example 1

Test it Now


1. Sum =1000156.0
2. Sum =1156.0
3. Multiplication =156000.0
4. Division =6.410256410256411
5. Reminder =64.0

Example 2

Test it Now


Enter your age:09
Sorry! You are not eligible.Try again after 44.0 years
Your year of birth is = 2009.0

Example 3

Test it Now


Enter any string:Himanshu@123
Exception in thread "main" java.lang.NumberFormatException: For input string: "Himanshu@123"
	at sun.misc.FloatingDecimal.readJavaFormatString(
	at sun.misc.FloatingDecimal.parseDouble(
	at java.lang.Double.parseDouble(

Example 4

Test it Now


Enter any string:himanshu@123
An exception java.lang.NumberFormatException: For input string: "himanshu@123" has occured.
Plz enter a valid double integer

Next TopicJava Double

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA