Java Data Type Tutorial - Java Double.valueOf(String s)








Syntax

Double.valueOf(String s) has the following syntax.

public static Double valueOf(String s)   throws NumberFormatException

Example

In the following code shows how to use Double.valueOf(String s) method.

The following code tries to convert "1.234" to double type.

public class Main {
  public static void main(String[] args) {
    
    System.out.println(Double.valueOf("1.234"));

  }
}

The output: