Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What happens if a runtime exception occured in a try-finally block?

 
Winston Liek
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What will happen if a runtime exception occured when executing a method in a try block but there are no catch nor declare is indicated but there is a finally block?

Will the code stop/terminate?
 
Tim Cooke
Sheriff
Pie
Posts: 3206
142
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The finally block will be executed, then the exception thrown.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Liek wrote:Will the code stop/terminate?

That's something you can easily try yourself Creating your own code snippets to experiment a little bit provides the best learning experience. You don't learn a programming language by just reading and reading; grab some tools and get your hands dirty ;)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic