介绍
The Double class wraps a value of the primitive type double in an object.
示例
public class Test {
public static void main(String[] args) {
Double d = Double.valueOf("0.123");
System.out.println(d);
}
}
源码
public final class Double extends Number implements Comparable<Double> {
public static String toString(double d) {
return FloatingDecimal.toJavaFormatString(d);
}
public static double parseDouble(String s) throws NumberFormatException {
return FloatingDecimal.parseDouble(s);
}
public static boolean isNaN(double v) {
return (v != v);
}
public static boolean isInfinite(double v) {
return (v == POSITIVE_INFINITY) || (v == NEGATIVE_INFINITY);
}
public static boolean isFinite(double d) {
return Math.abs(d) <= DoubleConsts.MAX_VALUE;
}
private final double value;
public Double(double value) {
this.value = value;
}
public Double(String s) throws NumberFormatException {
value = parseDouble(s);
}
}