Finally block is meant for cleanup.. and there is a rare possiblity of getting an exception there.. many cases it can be ignored.
If required we can handle that exception.. the similar way of putting that code inside the try/block.
If we are ignoring the exception inside the finally block, it is better to atleast log the stack trace.
thanks for your update but if we have any exception in finally block how the exception will catch as the finally block is hte last executer for that thread....
you will put the statement causing exception in try/catch block inside the finally block that is you will handle the exception normally as you do with exception outside the finally only thing is you are catching it within the finally block.
Chinna Eranna wrote:Finally block is meant for cleanup.. and there is a rare possiblity of getting an exception there..
Closing streams, database connections etc are usually done in a finally block, and the close() method of all these can throw a checked exception. It's not so rare as you think.
You are right that in most of those cases all you can do is log the exception.
Closing streams, database connections etc are usually done in a finally block, and the close() method of all these can throw a checked exception. It's not so rare as you think.
I said getting an exception.. is rare.
Post by:autobot
I think I'll just lie down here for a second. And ponder this tiny ad:
a bit of art, as a gift, that will fit in a stocking