Convert String to double in Java

后端 未结 14 1488
傲寒
傲寒 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:30

    If you have problems in parsing string to decimal values, you need to replace "," in the number to "."


    String number = "123,321";
    double value = Double.parseDouble( number.replace(",",".") );
    

提交回复
热议问题