先来看下两个得源码
valueOf方法
public static Double valueOf(String s) throws NumberFormatException {
return new Double(parseDouble(s));
}
parseDouble方法
public static double parseDouble(String s) throws NumberFormatException {
return FloatingDecimal.parseDouble(s);
}
关于parseDouble方法种用到得FloatingDecimal.parseDouble()方法代码太长我就不贴了。。有兴趣的可以自己去看一下
可以看出来,valueOf本质上还是调用的parseDouble方法,parseDouble()将String类型转换为double类型,valueOf再将其装箱。