Why use finally instead of code after catch [duplicate]

Because if an exception gets thrown no code after the try block is executed unless the exception is caught. A finally block is always executed no matter what happens inside your try block.

Leave a Comment