相关疑难解决方法(0)

catch和finally子句抛出异常

关于大学的Java问题,有这段代码:

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) {
        }
        finally {
            System.out.print(3);
            throw new Exception();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我被要求提供输出.我回答13Exception in thread main …

java exception-handling exception

150
推荐指数
6
解决办法
13万
查看次数

标签 统计

exception ×1

exception-handling ×1

java ×1