将字符串转换为float? [英] Convert string to float?
本文介绍了将字符串转换为float?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
正如标题所说。我不相信这是可能的,但如果它让我知道。
Just as title says. I don't believe it is possible to do this but if it is let me know.
这是我正在编写的bukkit(minecraft服务器)插件所需要的。我想接受一个命令:tnt [power]。 power是返回的字符串,我想转换为float。
This is needed for a bukkit (minecraft server) plugin I'm writing. I want to take a command: tnt [power]. Where power is the string returned that I want to convert to float.
谢谢
推荐答案
使用 Float。 valueOf(String)
进行转换。
valueOf()
之间的差异和 parseFloat()
只是返回。如果你想要 Float
(对象),请使用前者;如果你想要 float
数字,请使用后者。
The difference between valueOf()
and parseFloat()
is only the return. Use the former if you want a Float
(object) and the latter if you want the float
number.
这篇关于将字符串转换为float?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文