What is the finally block in Java?
The finally block in Java is used to execute code that must run regardless of whether an exception occurred or not, such as closing resources.
Exactly! The finally block ensures that some code is always executed after a try-catch, even if an exception is thrown.
Can you provide an example where using a finally block is necessary?