• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception in finally

 
kiran kumar
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
what happens when exception occurs at finally clause?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of those questions best answered by writing some code and seeing what happens.
 
camilo lopes
Ranch Hand
Posts: 202
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
haripriya vedula
Greenhorn
Posts: 24
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 143
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bill Shirley
Ranch Hand
Posts: 457
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic