home

Exceptions

Exceptions in Inheriting Methods

class MyException extends Exception {}

interface A {
    void a() throws MyException;
}

class B implements A {
    // no need for throws MyException
    public void a() {
    }
}
class MyException extends Exception {}

interface A {
    void a() throws MyException;
}

class B implements A {
    // throws Exception will not compile!
    public void a() throws MyException {
        throw new MyException();
    }
}