public class exceptionTest { private static Exception exception; public static void main(String[] args) throws Exception { callDoOne(); } public static void doOne() throws Exception { throw exception; } public static void callDoOne() throws Exception { doOne(); } }
class myException extends Exception{ } public class exceptionTest { private static Exception exception; private static myException myexception; public static void main(String[] args) throws Exception { callDoOne(); } public static void doOne() throws myException { throw myexception; } public static void callDoOne() throws Exception { doOne(); throw exception; } }这是在父类中的唯一一个catch子句语法上安全的原因。
如何处理Java异常的两个例子?,布布扣,bubuko.com
原文地址:http://blog.csdn.net/sunling_sz/article/details/28871391