public void throwTest() throws SQLException, IOException {
try{
} catch (SQLException e) {
}
}
Why is it that trying to catch an exception that will not occurr, will give a compilation error, whereas I can throw any Exception, it won't give an error? Both can be checked at compile time, so it would just make more sense to me if the behavior is the same?
In the given example, the catch-block will generate a compile time error: error: exception SQLException is never thrown in body of corresponding try statement } catch (SQLException e) {
When I remove the catch block, the code compiles just fine. This seems inconsistent to me. Is there any particular reason for this behavior?