| Author |
Exception in finally
|
kiran kumar
Greenhorn
Joined: May 24, 2008
Posts: 18
|
|
Hi, what happens when exception occurs at finally clause?
|
Thanks & Regards,<br />Bhuvan Samrat.
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
One of those questions best answered by writing some code and seeing what happens.
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
camilo lopes
Ranch Hand
Joined: Aug 08, 2007
Posts: 202
|
|
finally is optional, but you can use for close one file open for example. case you have forget. one point important that finally only is run.
|
Brazil - Sun Certified Java Programmer - SCJP 5
http://www.camilolopes.com/ About Java - Update every Week.
Guide SCJP - tips that you need know http://blog.camilolopes.com.br/livrosrevistaspalestras/
|
 |
haripriya vedula
Greenhorn
Joined: May 31, 2008
Posts: 24
|
|
|
finally creates a block of code that will be executed after try/catch block is completed. The finally block will execute whether or not exception is thrown..
|
 |
Eric Daly
Ranch Hand
Joined: Jul 11, 2006
Posts: 143
|
|
|
It's just the same as if you had an exception thrown anywhere else... try it and see. Will you need to handle it? That depends on whether or not it's a checked exception.
|
Studying for SCJP 6
|
 |
Bill Shirley
Ranch Hand
Joined: Nov 08, 2007
Posts: 457
|
|
Here's an example (yanked out of my code) of the case you are asking about... (note: i use this as a workaround, not as a standard copy mechanism)
|
Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
|
 |
 |
|
|
subject: Exception in finally
|
|
|