3
예외에 대한 질문 캐치 마지막 블록에 던져 가지고 : 나는 한 번 더 위의 코드를 실행하기 위해 노력했다예외는 마침내 발생과 catch 블록
class MyExc1 extends Exception {}
class MyExc2 extends Exception {}
class MyExc3 extends MyExc2 {}
public class C1 {
public static void main(String[] args) throws Exception {
try {
System.out.print(1);
q();
}
catch (Exception i) {
throw new MyExc2();
}
finally {
System.out.print(2);
throw new MyExc1();
}
}
static void q() throws Exception {
try {
throw new MyExc1();
}
catch (Exception y) {
System.out.print(3);
}
finally {
System.out.print(4);
throw new Exception();
}
}
}
합니다. 매번 다른 출력물을 제공합니다.
output 1: 1Exception in thread "main" 342test.MyExc1
at test.C1.main(C1.java:18)
output 2: 1342Exception in thread "main" test.MyExc1
at test.C1.main(C1.java:18)
output 3: 1Exception in thread "main" test.MyExc1
342 at test.C1.main(C1.java:18)
output4: 1Exception in thread "main" 34test.MyExc1
2 at test.C1.main(C1.java:18)
설명해주십시오.