Computer >> Computer tutorials >  >> Programming >> Java

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 −

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