-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexception_handling1.java
44 lines (37 loc) · 1.07 KB
/
exception_handling1.java
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
41
42
43
//arithmeticexception
// class ex12 {
// public static void main(String[] args) {
// System.out.println(1);
// System.out.println(2);
// System.out.println(10 / 0);
// }
// }
/* error: unreported exception InterruptedException;
must be caught or declared to be thrown
Thread.sleep(3000)*/
// class ex12 {
// public static void main(String[] args) {
// System.out.println(1);
// System.out.println(2);
// Thread.sleep(3000);
// System.out.println(3);
// System.out.println(4);
// }
// }
//solved InterruptedException using throws keyword
// class ex12 {
// public static void main(String[] args) throws InterruptedException {
// System.out.println(1);
// System.out.println(2);
// Thread.sleep(3000);
// System.out.println(3);
// System.out.println(4);
// }
// }
// /*Exception in thread "main" java.lang.NegativeArraySizeException: -1
// at A.main(...)*/
// class A {
// public static void main(String[] args) {
// int a[] = new int[-1];
// }
// }