将字符串转换为double [英] conversion of string to double
问题描述
我有一个字符串s =" 11316500.00"
i希望将它转换为double并得到dTot = 11016500.00
我该怎么做?请帮助
Ive got a string s="11316500.00"
i want to convert it to double and get dTot = 11016500.00
How do i do this? please help
推荐答案
我有一个字符串s =" 11316500.00"
i想把它转换成双倍并得到dTot = 11016500.00
我该怎么做?请帮助
Ive got a string s="11316500.00"
i want to convert it to double and get dTot = 11016500.00
How do i do this? please help
看看parseDouble()
http://java.sun.com/j2se/1.4.2/docs /api/java/lang/Double.html#parseDouble(java.lang.String)
have a look at parseDouble()
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Double.html#parseDouble(java.lang.String)
我有一个字符串s =" 11316500.00"
i希望将其转换为double并获得dTot = 11016500.00
我该怎么做?请帮助
Ive got a string s="11316500.00"
i want to convert it to double and get dTot = 11016500.00
How do i do this? please help
杀猫的方法有很多种。这取决于你使用哪种方法以及你想要实现的目标。
我将通过双层包装类的匿名实例化来实现它,因为所有包装类都有一个构造函数在String参数中创建包装器实例 - 使用输入字符串。然后使用Double包装类的no-arg unboxing方法 - (doubleValue()) - 获取double类型的原始值。这一切都在一行中完成。这是 - :
There are many ways to kill a cat. It depends on which method suites u and what you want to achieve.
I will do it by an anonymous instantiation of a Double wrapper class, - because all wrapper classes have a constructor that takes in a String argument to create the wrapper instance - with your input string. Then use the no-arg unboxing method of that Double wrapper class -(doubleValue()) -to get the primitive value of type double. all this is done in one line. Here it is -:
查看parseDouble( )
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Double.html#parseDouble(java.lang.String)
have a look at parseDouble()
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Double.html#parseDouble(java.lang.String)
i没有从上面的链接中获得解决方案.....
请帮忙
i did not get a solution from the above link.....
please help
这篇关于将字符串转换为double的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!