转自:
http://www.java265.com/JavaCourse/202205/3576.html
下文笔者讲述Double.valueOf()方法的功能简介说明,如下所示:
public static Double valueOf (double value); public static Double valueOf (String value); valueOf可能出现异常的情况: NullPointerException: 当传入的值是null时,则会报此异常错误 NumberFormatException: 传入的数值异常
public class ValueOfDoubleClass { public static void main(String[] args) { Double ob1 = new Double("80.30"); Double ob2 = new Double("80.30"); System.out.println("ob1: " + ob1); System.out.println("ob2: " + ob2); Double value1 = ob1.valueOf(90.11d); String s = "90"; Double value2 = ob2.valueOf(s); System.out.println("ob1.valueOf(80.11d): " + value1); System.out.println("ob2.valueOf(s): " + value2); } }