3
Answers

Try Catch Finally

David

David

18y
2.4k
1
Hi.

I was wondering if anybody could explain to me the purpose of the Finally block in exception handling. For example, what is the difference between these two pieces of code.

Example 1:

try
{
// open a file
}
catch (IOException ioe)
{
// log the error or something
}
finally
{
// do more stuff
}

Example 2:

try
{ // open a file
}
catch (IOException ioe)
{
// log the error or something
}
// do more stuff

Thanks,

Dave
Answers (3)