Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1d8b3ae

Browse files
committed
Check parseInt
1 parent b12a25d commit 1d8b3ae

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/main/java/com/hackerrank/algorithms/recursion/RecursiveDigitSum.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ public class RecursiveDigitSum {
2424
private static int superDigit(String n, int k) {
2525
if(n == null) throw new Exception("by input exception [" + n + "]");
2626
if (n.length() == 1 && k == 0) {
27-
return Integer.parseInt(n);
27+
try {
28+
return Integer.parseInt(n);
29+
}catch (Exception e) {
30+
throw new Exception("by input exception [" + n + "]");
31+
}
2832
}
2933

3034
Long sum = 0L;

0 commit comments

Comments
 (0)