Possible Duplicate:
Why use Finally in Try … Catch
Why should we not use the catch block to clean up code?
I have not used the error-handling techniques as much, but am starting to use them for just about every program now. about time
So, while going through articles/documentations, i came across the finally block.
And as it suggests, the finally block runs irrespective of whether there is an exception or not(Of course it wont run, if there is a forced shutdown of the JVM or the PC). Also finally block is usually used for cleaning up code(resources).
So basically, if my code does not have an exception coming up, then why should i clean up the code. Shouldn't i put the cleanup code in the catch block rather than the finally block.
I tried looking for questions similar, but none asked this question it seems. So i went ahead and created a question :D