View Havish  Goswami 's Profile
What is the use of the finally block? Is finally block in Java guaranteed to be called? When finally block is NOT called?
Hi Java Professionals,

Please elaborate the answer
Asked by Havish Goswami | Dec 7 2017 | Report this Report abuse
Replies (7)
View Chinmay  Hegde 's Profile
Finally block is used if there is code that must be executed regardless of whether the exception is thrown or not.In the Finally block,clean up code related to closing of database connections,closing of files is written.

Finally block is not called in the conditions mentioned in the above post.
Dec 16 2017 | Report this Report abuse
View Nirupama  Pathak 's Profile
Finally block is used if there is code that must be executed regardless of whether the exception is thrown or not.In the Finally block,clean up code related to closing of database connections,closing of files is written.

Finally block is not called in the conditions mentioned in the above post.
Dec 16 2017 | Report this Report abuse
View Tanya  Sharma 's Profile
if system.exit() will be called in try/catch bolck i.e if jvm will get shutdown then finally block will not be called.
Dec 15 2017 | Report this Report abuse
View Shatish  Rao 's Profile
if system.exit() will be called in try/catch bolck i.e if jvm will get shutdown then finally block will not be called.
Dec 15 2017 | Report this Report abuse
View Shatish  Rao 's Profile
Java finally block is a block that is used to execute important code such as closing connection, stream etc

Visit this helpful article to better understand

https://www.mindstick.com/Articles/12106/exception-handling-in-java-guidelines-on-the-use-of-finally-block

http://www.java-samples.com/showtutorial.php?tutorialid=296
Dec 15 2017 | Report this Report abuse
View Roshan  shah 's Profile
Java finally block is a block that is used to execute important code such as closing connection, stream etc

Visit this helpful article to better understand

https://www.mindstick.com/Articles/12106/exception-handling-in-java-guidelines-on-the-use-of-finally-block

http://www.java-samples.com/showtutorial.php?tutorialid=296
Dec 14 2017 | Report this Report abuse
View Nirupama  Pathak 's Profile
finally block is used to perform clean-up activities or code clean-up like closing database connection & closing streams or file resources, etc

http://www.benchresources.net/finally-block-in-java-exception-handling/

http://www.benchresources.net/return-statement-with-finally-block-in-java/
Dec 14 2017 | Report this Report abuse