java.lang.Double valueOf(String s)

Syntax:

public static Double valueOf(String s) throws NumberFormatException

Java Code Example :

This java example source code demonstrates the use of valueOf(String s) method of Double class.  This method returns the double value of the string method input.

The example evaluates two values from string input and then multiple them to get the result. And then to further check the behavior of the valueOf method, we have asked for the user input for the base and height of a right triangle. From the user input we have calculated the area of the triangle.

Sample Output :

Running the above example source code will give the following output

Double valueOf(String s) method example

Double valueOf(String s) method example

Suggested Reading List :

References :