为什么调用函数时需要“抛出异常”?
class throwseg1
{
void show() throws Exception
{
throw new Exception("my.own.Exception");
}
void show2() throws Exception // Why throws is necessary here ?
{
show();
}
void show3() throws Exception // Why throws is necessary here ?
{
show2();
}
public static void main(String s[]) throws Exception // Why throws is necessary here ?
{
throwseg1 o1 = new throwseg1();
o1.show3();
}
}
为什么编译器报告方法 、 和 具有show2()
show3()
main()
未报告的异常 必须捕获或声明要引发的异常
当我从这些方法中删除时?throws Exception