class A
{
public void method throws IOException(){}
}
// 错误
class B
{
public void method throws FileNotFoundException(){}
}
// 错误
class C
{
public void method throws Exception(){}
}
// 错误
class D
{
public void method throws IOException,MyException(){}
}
// 正确
class F
{
public void method(){}
}
重写的方法必须和原方法抛出的异常一致或者不抛异常
时间: 2025-01-28 00:17:27