- package select1;
- class ExceptionA extends Exception {
- public ExceptionA(String str) {
- super();
- }
- }
- class ExceptionB extends ExceptionA {
-
- public ExceptionB(String str) {
- super(str);
- }
- }
- class ExceptionC extends ExceptionA {
- public ExceptionC(String str) {
- super(str);
- }
- }
- public class yichang6 {
- static void f() throws ExceptionB{
- throw new ExceptionB("exception b");//为什么这一句没输出
- }
- static void g() throws ExceptionC {
- try {
- f();
- } catch (ExceptionB e) {
- ExceptionC c = new ExceptionC("exception a");
- throw c;
- }
- }
- public static void main(String[] args) {
- try {
- g();
- } catch (ExceptionC e) {
- e.printStackTrace();
- }
- }
-
- }
复制代码 |