你的上面父类抛的异常是IOException 而子类抛得异常是Exception 这样不行。。要么在上面加Exception
import java.io.IOException;
public class SuperClass
{
public void start() throws IOException,Exception
{
throw new IOException("Not able to open file");
}
}
class SubClass extends SuperClass
{
public void start() throws Exception
{
throw new IOException("Not able to start");
}
}
要么如下代码 都抛IOException
import java.io.IOException;
public class SuperClass
{
public void start() throws IOException
{
throw new IOException("Not able to open file");
}
}
class SubClass extends SuperClass
{
public void start() throws IOException
{
throw new IOException("Not able to start");
}
} |