-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathException.java
62 lines (50 loc) · 1.25 KB
/
Exception.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import java.io.*;
//import java.
class TestException{
public static void main(String[] args) {
try{
FileInputStream f = new FileInputStream("test.txt");
}
catch(Exception e){
e.printStackTrace();
}
TestException2 testException = new TestException2();
try{
testException.test();
}
catch(Exception e){
System.out.println("exception occur !");
}
try{
testException.test1();
}
catch(Exception e){
System.out.println("exception occur in test1 !");
}
try{
testException.test2();
}
catch(Exception e){
System.out.println("exception occur in test2 !");
}
}
}
class TestException2 {
public void test() throws NullException{
throw new NullException("test.txt");
}
public void test1() throws MyException{
throw new MyException();
}
public void test2() throws MyException2{
throw new MyException2();
}
}
class MyException extends Exception{
}
class MyException2 extends RuntimeException{
}
class NullException extends Exception{
NullException(String str){
}
}