我怎样才能将字符串转换为加倍? [英] How can I convert string to double?

查看:242
本文介绍了我怎样才能将字符串转换为加倍?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Android应用程序。我需要将字符串转换为加倍。我该怎么办呢?

I am developing an android app. I need to convert string to double. How can I do it?

推荐答案

您只需要这样的:

double d=Double.parseDouble(myString);

如果你的字符串价值不能被解析一倍它会抛出 NumberFormatException异常。因此,更好地你把 parseDouble 语句try catch块内。

If your String value cannot be parsed to double it will throw NumberFormatException. So better you put the parseDouble statement inside try catch block.

这篇关于我怎样才能将字符串转换为加倍?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆