- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHackerrankJava0055.java
More file actions
Latest commit
26 lines (18 loc) · 603 Bytes
/
Copy pathHackerrankJava0055.java
File metadata and controls
26 lines (18 loc) · 603 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
importjava.util.Scanner;
publicclassHackerrankJava0055 {
publicstaticvoidmain(String[] args) {
// Java Exception Handling (Try-catch)
// https://www.hackerrank.com/challenges/java-exception-handling-try-catch/problem?isFullScreen=true
Scannerscanner = newScanner(System.in);
try {
intx = scanner.nextInt();
inty = scanner.nextInt();
System.out.println(x / y);
} catch (ArithmeticExceptione) {
System.out.println(e.getClass().getName() + ": " + e.getMessage());
} catch (Exceptione) {
System.out.println(e.getClass().getName());
}
scanner.close();
}
}