-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_38_Try_catch_vs_throws.java
More file actions
36 lines (34 loc) · 1000 Bytes
/
Copy path_38_Try_catch_vs_throws.java
File metadata and controls
36 lines (34 loc) · 1000 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
27
28
29
30
31
32
33
34
35
36
//class lp{
// public static void Wait() throws InterruptedException {
// for (int i = 1; i <= 10;i++)
// {
// System.out.println(i);
// Thread.sleep(1000);
// }
// }
//
// public static void main(String[] args) throws InterruptedException{
// Wait();
// System.out.println("main methord ended");
// }
//}
class lp{
public static void Wait() throws InterruptedException {
for (int i = 1; i <= 10;i++)
{
System.out.println(i);
Thread.sleep(1000);
}
}
// best approch to handle Exception with try catch because it has 100% girenty to terminate normally.
public static void main(String[] args) {
try {
Wait();
System.out.println(10/0);
}
catch (Exception e){
System.out.println("Exception Handled...!");
}
System.out.println("main methord ended");
}
}