KnowledgeBoat Logo
|

Computer Applications

Which of the following is the correct method to convert a String to a double in Java?

Java Library Classes

1 Like

Answer

Double.parseDouble(String)

ReasonDouble.parseDouble(String) method converts a String representation of a number into a primitive double.

Analysing other options:

  • String.toDouble()Incorrect. This method does not exist in Java.
  • Double.parseDouble()Incorrect. This is syntactically incomplete, as it requires a String argument.
  • Double.valueOf(String)Incorrect. This converts the String to a Double object, not a primitive double.

Answered By

1 Like


Related Questions