记录一下这个知识点,不然老是忘记
(Double.valueOf(positionDataResponse.acb21i).intValue()
来都来了不妨看一下源码吧
public static Double valueOf(String string) throws NumberFormatException {
return parseDouble(string);
}
public static double parseDouble(String string) throws NumberFormatException {
return StringToReal.parseDouble(string);
}
public static double parseDouble(String s) {
s = s.trim();
int length = s.length();
if (length == 0) {
throw invalidReal(s, true);
}
// See if this could be a named double
char last = s.charAt(length - 1);
if (last == 'y' || last == 'N') {
return parseName(s, true);
}
// See if it could be a hexadecimal representation.
// We don't use startsWith because there might be a leading sign.
if (s.indexOf("0x") != -1 || s.indexOf("0X") != -1) {
return HexStringParser.parseDouble(s);
}
StringExponentPair info = initialParse(s, length, true);
if (info.infinity || info.zero) {
return info.specialValue();
}
double result = parseDblImpl(info.s, (int) info.e);
if (Double.doubleToRawLongBits(result) == 0xffffffffffffffffL) {
throw invalidReal(s, true);
}
return info.negative ? -result : result;
}
//当你用Integer.valueof("2500.0")时就会出现
private static NumberFormatException invalidReal(String s, boolean isDouble) {
throw new NumberFormatException("Invalid " + (isDouble ? "double" : "float") + ": \"" + s + "\"");
}