提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
将字符串转换为双精度示例
public class Main { /* 来 自* 时 代 J a v a */ public static void main(String[] args) { //1. Construct Double using constructor. Double dObj1 = new Double("100.564"); System.out.println(dObj1); //2. Use valueOf method of Double class. This method is static. String str1 = "100.476"; Double dObj2 = Double.valueOf(str1); System.out.println(dObj2); /* To convert a String object to a double primitive value parseDouble method of Double class. */ String str2 =