Skip to content

Commit 8bf9a77

Browse files
solves java try catch exception handlin
1 parent bdb9b03 commit 8bf9a77

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ The Java Domain is further Divided into the following sub-domains.
126126
| Problem | Solution Link | Difficulty |
127127
|---------|---------------|------------|
128128
| [Java Exception Handling](https://www.hackerrank.com/challenges/java-exception-handling) | [Solution](https://github.com/anishLearnsToCode/hackerrank-java/blob/master/src/JavaExceptionHandling.java) | Easy |
129-
| [Java Exception Handling (try-catch)](https://www.hackerrank.com/challenges/java-exception-handling) | | Easy |
129+
| [Java Exception Handling (try-catch)](https://www.hackerrank.com/challenges/java-exception-handling-try-catch/problem) | | Easy |
130130

131131

132132
### Java Advanced
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// https://www.hackerrank.com/challenges/java-exception-handling-try-catch/problem
2+
3+
import java.util.InputMismatchException;
4+
import java.util.Scanner;
5+
6+
public class JavaExceptionHandlingTryCatch {
7+
public static void main(String[] args) {
8+
Scanner scanner = new Scanner(System.in);
9+
try {
10+
int x = scanner.nextInt();
11+
int y = scanner.nextInt();
12+
System.out.println(x / y);
13+
} catch (InputMismatchException exception) {
14+
System.out.println(exception.getClass().getName());
15+
} catch (Exception exception) {
16+
System.out.println(exception);
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)