Skip to content

Commit 7179718

Browse files
authored
Update ParseInteger.java
Fixed error for empty string.
1 parent 4ac4a62 commit 7179718

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Maths/ParseInteger.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static void main(String[] args) {
1616
* @throws NumberFormatException if the {@code string} does not contain a parsable integer.
1717
*/
1818
public static int parseInt(String s) {
19-
if (s == null) {
19+
if (s == null || s.length() == 0) {
2020
throw new NumberFormatException("null");
2121
}
2222
boolean isNegative = s.charAt(0) == '-';

0 commit comments

Comments
 (0)