-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTryCatch.java
More file actions
33 lines (28 loc) · 762 Bytes
/
Copy pathTryCatch.java
File metadata and controls
33 lines (28 loc) · 762 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
package hello;
class NumException extends Exception {
public NumException(String str){
super(str);
}
}
class TryCatch {
static void Check(int num) throws NumException{
if(num<100){
throw new NumException("ERROR : The number entered is less than 100.");
}
else{
System.out.println("No Exception Found.");
}
}
public static void main(String args[]){
try {
Check(11);
}
catch (NumException e) {
System.out.println("Exception");
System.out.println(e.getMessage());
}
finally{
System.out.println("Reached To Finally Block!!");
}
}
}