Update ParseInteger.java

Fixed error for empty string.
This commit is contained in:
lollerfirst 2020-06-09 08:40:46 +02:00 committed by GitHub
parent 4ac4a62a7f
commit 7179718df2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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