下面给个小例子,来验证一下error的捕获。
public TestCatchError(){
super();
}
public TestCatchError(String msg){
super(msg);
}
public static void main(String[] args) {
try {
throw new TestCatchError("test catch error");
} catch (Throwable t) {
System.out.println("step in the catch ~");
t.printStackTrace();
}
}
}
运行结果:
新闻热点
疑难解答