They both convert a String to a double value but wherease the parseDouble() method returns the primitive double value, the valueOf() method further converts the primitive double to a Double wrapper class object which contains the primitive double value.

The conversion from String to primitive double may throw NFE(NumberFormatException) if the value in String is not convertible into a primitive double.



Double.parseDouble(String s) will return a primitive double type . Double.valueOf(String s)will return a Wrapper Object of type Double.

So , for eg.

double d = Double.parseDouble("1");

Double d = Double.valueOf("1");

Morover,valueOf() is an overloaded method. It has its two variant :

  1. Double valueOf(String s)
  2. Double valueOf(Double d)

    Where as parseDouble is a single method with the following signature :

  3. double parseDouble(String s)