• 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: 171
  • 0
  • 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: 2722
111
Clojure IntelliJ IDE Java
  • 0
  • 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: 9208
78
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • 0
  • 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 ;)
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic