阅读程序写结果 (java程序设计题)
publicclassRethrowing{publicstaticvoidf()throwsException{System.out.println("originat...
public class Rethrowing {
public static void f() throws Exception {
System.out.println("originating the exception in f()");
throw new Exception("thrown from f()");
}
public static void g() throws Throwable {
try {
f();
} catch(Exception e) {
System.out.println("Catch Exception Inside g()");
throw e;
} finally {
System.out.println("Finally executed in g()");
}
}
public static void main(String[] args) throws Throwable {
try {
g();
} catch(Exception e) {
System.out.println("Caught Exception in main");
return;
} finally {
System.out.println("Finally executed in main()");
}
}
} 展开
public static void f() throws Exception {
System.out.println("originating the exception in f()");
throw new Exception("thrown from f()");
}
public static void g() throws Throwable {
try {
f();
} catch(Exception e) {
System.out.println("Catch Exception Inside g()");
throw e;
} finally {
System.out.println("Finally executed in g()");
}
}
public static void main(String[] args) throws Throwable {
try {
g();
} catch(Exception e) {
System.out.println("Caught Exception in main");
return;
} finally {
System.out.println("Finally executed in main()");
}
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询