Double类parseDouble()方法 (Double class parseDouble() method)
- parseDouble() method is available in java.lang package. - parseDouble()方法在java.lang包中可用。 
- parseDouble() method is used to return the double value corresponding to the given String or in other words we can say this method is used to convert a string value to double value. - parseDouble()方法用于返回对应于给定String的double值,换句话说,我们可以说此方法用于将字符串值转换为double值。 
- parseDouble() method is a static method, it is accessible with the class name too and if we try to access the method with the class object then also we will not get an error. - parseDouble()方法是一个静态方法,也可以使用类名进行访问,如果我们尝试使用类对象访问该方法,那么我们也不会收到错误。 
- parseDouble() method may throw a NumberFormatException at the time of conversion from string double, - 从字符串double转换时, parseDouble()方法可能会引发NumberFormatException, - NumberFormatException: In this exception, when the string argument does not have parsable double. - NumberFormatException:在此异常中,当string参数没有可分析的double时。 
Syntax:
句法:
    public static double parseDouble(String str);
Parameter(s):
参数:
- String str – represents the string value to be parsed. - 字符串str –表示要解析的字符串值。 
Return value:
返回值:
The return type of this method is double, it returns the corresponding double value.
此方法的返回类型为double ,它返回相应的double值。
Example:
例:
// Java program to demonstrate the example 
// of parseDouble(String str) method of Double class
public class ParseDoubleOfDoubleClass {
public static void main(String[] args) {
// Variables initialization
String str1 = "100";
String str2 = "6.7";
// Object initialization
Double d1 = new Double(str2);
// It convert string into double by calling parseDouble() method
// and store the result in another variable of double type
double result = d1.parseDouble(str1);
// Display result
System.out.println("d1.parseDouble(str1): " + result);
}
}
Output
输出量
d1.parseDouble(str1): 100.0
翻译自: https://www.includehelp.com/java/double-class-parsedouble-method-with-example.aspx