Home » Java programming language

Java Double class parseDouble() method with example

Double class parseDouble() method: Here, we are going to learn about the parseDouble() method of Double class with its syntax and example.
Submitted by Preeti Jain, on September 23, 2019

Double class parseDouble() method

  • parseDouble() method is available in java.lang package.
  • parseDouble() method is used to return the double value corresponding to the given String or in other words we can say this method is used to convert a string value to double value.
  • parseDouble() method is a static method, it is accessible with the class name too and if we try to access the method with the class object then also we will not get an error.
  • parseDouble() method may throw a NumberFormatException at the time of conversion from string double,
    NumberFormatException: In this exception, when the string argument does not have parsable double.


    public static double parseDouble(String str);


  • String str – represents the string value to be parsed.

Return value:

The return type of this method is double, it returns the corresponding double value.


// Java program to demonstrate the example 
// of parseDouble(String str) method of Double class

public class ParseDoubleOfDoubleClass {
    public static void main(String[] args) {

        // Variables initialization
        String str1 = "100";
        String str2 = "6.7";

        // Object initialization
        Double d1 = new Double(str2);

        // It convert string into double by calling parseDouble() method
        // and store the result in another variable of double type
        double result = d1.parseDouble(str1);

        // Display result
        System.out.println("d1.parseDouble(str1): " + result);


d1.parseDouble(str1): 100.0

Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.