From 7179718df290ccf0ecaaab044508aa309ffada8b Mon Sep 17 00:00:00 2001 From: lollerfirst <43107113+lollerfirst@users.noreply.github.com> Date: Tue, 9 Jun 2020 08:40:46 +0200 Subject: [PATCH] Update ParseInteger.java Fixed error for empty string. --- Maths/ParseInteger.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Maths/ParseInteger.java b/Maths/ParseInteger.java index 91177bb4..c9c11528 100644 --- a/Maths/ParseInteger.java +++ b/Maths/ParseInteger.java @@ -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) == '-';