3 ms·
In this case, do_something_finally() will never be called. try { throw new IOException("bad"); } catch ( NotAnIOException e) { System.o
by yummyfajitas 16y ago
In this case, do_something_finally() will never be called.
try {
throw new IOException("bad");
} catch ( NotAnIOException e) {
System.out.println("This is something I expected to happen.");
}
do_something_finally();
With a finally block, it would be, and the IOException would then be bubbled up to the caller. Without finally, you need to do this:
try {
throw new IOException("bad");
} catch ( NotAnIOException e) {
System.out.println("This is something I expected to happen.");
} catch (Exception e) {
do_something_finally();
throw e;
}
do_something_finally();
- dan_netwalker 16y agoThanks, now that has a lot more sense