Convert String to double in Java

后端 未结 14 1678
傲寒
傲寒 2020-11-22 05:52

How can I convert a String such as \"12.34\" to a double in Java?

14条回答
  •  北荒
    北荒 (楼主)
    2020-11-22 06:29

    To convert a string back into a double, try the following

    String s = "10.1";
    Double d = Double.parseDouble(s);
    

    The parseDouble method will achieve the desired effect, and so will the Double.valueOf() method.

提交回复
热议问题