Convert String to Double in Java

JavaObject Oriented ProgrammingProgramming

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
raja
Published on 26-Sep-2019 13:01:25
Advertisements