Convert String to Double in Java


Let’s say the following is our string −

String str = "55.2";

Now, convert the above string to double using parseDouble() in Java −

double res = Double.parseDouble("23.6");

Example

Following is the program to convert String to Double in Java −

 Live Demo

public class Demo {
   public static void main(String args[]){
      String str = "55.2";
      double res = Double.parseDouble("23.6");
      System.out.println("Double (String to Double) = "+res);
   }
}

Output

Double (String to Double) = 23.6

Updated on: 26-Sep-2019

262 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements