All for Joomla All for Webmasters

Java String to double

We can convert String to double in java using Double.parseDouble() method.


It is generally used if we have to perform mathematical operations on the string that contains double number. Whenever we get data from textfield or textarea, entered data is received as a string. If entered data is double, we need to convert string to double. To do so, we use Double.parseDouble() method.


The parseDouble() is the static method of Double class. The signature of parseDouble() method is given below:

  1. public static double parseDouble(String s)

Java String to double Example

Let’s see the simple code to convert string to double in java.

  1. double d=Double.parseDouble(“23.6”);

Let’s see the simple example of converting String to double in java.

  1. public class StringToDoubleExample{
  2. public static void main(String args[]){
  3. String s=“23.6”;
  4. double d=Double.parseDouble(“23.6”);
  5. System.out.println(d);
  6. }}


submit to reddit

Leave a Reply