- class F{
-
- public F(){}
-
- public void run(){ }
- }
- class Child extends F{
-
- public Child(){}
- /*
- @Override
- public void run() throws Exception { //这样不行
- super.run();
- throw new Exception();
-
- }
- */
- /*
- @Override
- public void run() { //这样可以
- super.run();
- try {
- throw new Exception();
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
- */
- @Override
- public void run() { //这样可以
- super.run();
- throw new RuntimeException();
- }
- }
复制代码 你可以自己测试下 |