JavaAdvanced#exceptions

What happens if an exception is thrown in a finally block?

It suppresses any exception from the try/catch block and propagates instead, which can hide the original error — a good reason to avoid throwing exceptions in finally blocks.

Example
try {
  try { throw new RuntimeException("original"); }
  finally { throw new RuntimeException("from finally"); }
} catch (RuntimeException e) {
  System.out.println(e.getMessage()); // "from finally", original is lost
}

Related Questions

1
JavaIntermediate#exceptions

What is multi-catch in Java 7+?

Open
2
JavaIntermediate#concurrency

What is a race condition and how do you prevent it?

Open
3
JavaAdvanced#concurrency

What is a deadlock and how can it be avoided?

Open