from @RogerRiggs

This commit is contained in:
Shaojin Wen 2026-01-27 09:22:17 +08:00
parent 6c770a89d6
commit 54a2cbee2a
3 changed files with 5 additions and 11 deletions

View File

@ -492,11 +492,7 @@ public final class Integer extends Number
if (s == null) {
throw NumberFormatException.nullInput();
}
int len;
if ((len = s.length()) == 0) {
throw NumberFormatException.forInputString(s);
}
return parseInt(s, 0, len, radix);
return parseInt(s, 0, s.length(), radix);
}
static boolean isDigitLatin1(int ch) {

View File

@ -525,11 +525,7 @@ public final class Long extends Number
if (s == null) {
throw NumberFormatException.nullInput();
}
int len;
if ((len = s.length()) == 0) {
throw NumberFormatException.forInputString(s);
}
return parseLong(s, 0, len, radix);
return parseLong(s, 0, s.length(), radix);
}
/**

View File

@ -56,7 +56,9 @@ public class NumberFormatException extends IllegalArgumentException {
/**
* Factory method for making a {@code NumberFormatException}
* given the specified input which caused the error.
* given the specified input which caused the error. This method
* is specifically for radix 10 (decimal) parsing and calls
* {@link #forInputString(String, int) forInputString(s, 10)}.
*
* @param s the input causing the error
*/