62,621
社区成员
发帖
与我相关
我的任务
分享
package com.think.chapter12;
class A extends Exception{
@Override
public String toString() {
return "this is A";
}
}
class B extends Exception{
@Override
public String toString() {
return "this is B";
}
}
public class LostMessage {
void f() throws A{
throw new A();
}
void g() throws B{
throw new B();
}
public static void main(String[] args) {
LostMessage lm = new LostMessage();
try{
try{
lm.f();
}finally{
lm.g();
}
}catch(Exception b){
b.printStackTrace();
}finally{
System.out.println("finally");
//return;
}
}
}
........
System.setOut(print);
System.setErr(print);
String s = null;
try{
System.out.println("test");
s.charAt(1);
}catch(Exception ex){
ex.printStackTrace();
}finally{
System.err.println(e);
}
print.close();
......