Java compiler insists that all exceptions thrown by the new method must be
the same as, or subclasses of, the exception classes thrown by the original method.
import java.io.EOFException;
import java.io.IOException;
import java.net.MalformedURLException;
class BaseClass {
public void method() throws IOException {
}
}
class SubOne extends BaseClass {
public void method() throws IOException {
}
}
class SubTwo extends BaseClass {
public void method() {
}
}
class SubThree extends BaseClass {
public void method() throws EOFException, MalformedURLException {
}
}
|