Finally block in Java is the block of code in association with try/catch block which will execute the program even if it throws any Exceptions, which also means if there is an error like Runtime Error or Arithmetic Error in the program, it will show the statements which will come under finally block. It always executes after the try/catch block. We have already covered  Exception Handling and  Throw exception in Java.

Finally block in Java

Finally block is used to execute necessary code such as closing connection, stream, etc. Java finally blocks always executed whether an exception is handled or not. The final block follows, try or catch block. The final block must be associated with the try block, you cannot use finally without the try block. You should place those statements in this block that must be executed always.

#java #finally block

Finally block in Java Example | Java Finally Block Tutorial
2.05 GEEK