Convert a String to a double type number in Java

Java 8Object Oriented ProgrammingProgramming

To convert a String to a double type number in Java, use the Double.parseDouble() method.

Here is our string.

String str = "699.7e130";

Let us now convert the above string to double.

double val = Double.parseDouble(str);

Example

 Live Demo

public class Demo {
    public static void main(String args[]) {
       String str = "699.7e130";
       double val = Double.parseDouble(str);
       System.out.println(val);
    }
}

Output

6.997E132
raja
Published on 12-Dec-2018 09:32:07
Advertisements