据我所知,ParseDouble函数就像这样:
Double parseDouble(String s) throws ... {
return new Double(Double.valueOf(s));
}
Run Code Online (Sandbox Code Playgroud)
Mic*_*ker 20
逻辑是相同的,但Double.valueOf()的返回值返回一个堆分配的Double对象,其中parseDouble返回一个原始double.您的代码示例不太正确.java源代码如下:
public static double parseDouble(String s) throws NumberFormatException {
return FloatingDecimal.readJavaFormatString(s).doubleValue();
}
public static Double valueOf(String s) throws NumberFormatException {
return new Double(FloatingDecimal.readJavaFormatString(s).doubleValue());
}
Run Code Online (Sandbox Code Playgroud)