Thursday, July 29, 2010

Finally in java | exception finally block

Finally in java | exception finally block

Finally is a keyword. Finally block will executed when exception occure or not (it always executed).

Finally block executed after try-catch. It's executed before the method return.

It's used for the file and unresource closed.

ex:1

try{
}catch(){
}
finally{
}

ex:2

try{
}
finally{
}

Note
-------
If a catch clause invokes System.exit() the finally clause WILL NOT execute.

No comments:

Post a Comment