-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyexceeption.java
More file actions
40 lines (35 loc) · 1.01 KB
/
myexceeption.java
File metadata and controls
40 lines (35 loc) · 1.01 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import java.util.Scanner;
public class MyExp {
public void m1() throws ArithmeticException{
m2();
}
public void m2() throws ArithmeticException{
System.out.println(10/0);
}
public static void main(String[] args) throws ArithmeticException {
MyExp obj = new MyExp();
try {
obj.m1();
}
catch (ArithmeticException obj1){
System.out.println(obj);
}
obj.m1();
System.out.println("end of the main method");
// Here exception is handled by the default exception handling mechanism
// // try with resources
//
//
// try(Scanner sc = new Scanner(System.in)){
// int i = Integer.parseInt(sc.next());
// }
// catch(Exception obj){
// obj.printStackTrace();
//
// System.out.println(obj.toString());
// System.out.println(obj.getMessage());
// System.out.println(obj);
// }
// System.out.println("end of the method");
}
}