Merge pull request #1347 from lollerfirst/patch-1, close #1345

Update ParseInteger.java
This commit is contained in:
Yang Libin
2020-06-12 09:22:17 +08:00
committed by GitHub

View File

@ -16,7 +16,7 @@ public class ParseInteger {
* @throws NumberFormatException if the {@code string} does not contain a parsable integer. * @throws NumberFormatException if the {@code string} does not contain a parsable integer.
*/ */
public static int parseInt(String s) { public static int parseInt(String s) {
if (s == null) { if (s == null || s.length() == 0) {
throw new NumberFormatException("null"); throw new NumberFormatException("null");
} }
boolean isNegative = s.charAt(0) == '-'; boolean isNegative = s.charAt(0) == '-';