-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFinally.java
44 lines (42 loc) · 1021 Bytes
/
Finally.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
44
public class Finally {
public static int greet(){
try{
int a = 50;
int b = 10;
int c = a/b;
return c;
}
catch(Exception e){
System.out.println(e);
}
finally {
System.out.println("Cleaning up resources...This is the end of this function");
}
return -1;
}
public static void main(String[] args) {
int k = greet();
System.out.println(k);
int a = 7;
int b = 9;
while(true){
try{
System.out.println(a/b);
}
catch (Exception e){
System.out.println(e);
break;
}
finally{
System.out.println("I am finally for value of b = " + b);
}
b--;
}
try{
System.out.println(50/3);
}
finally {
System.out.println("Yes this is finally");
}
}
}