• Post Reply Bookmark Topic Watch Topic
  • New Topic

Handling Exceptions  RSS feed

 
Urs Waefler
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the code: I understand that the finally block will always execute (except when there is a System.exit() in try or catch); it will return 10.0. I do not understand why it does not return 0.0 too. I think first it returns 0.0 after it returns 10.0; but that is not true. What happens whith the try block?
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The method can only return one thing; whatever the try returns is overridden by the finally. That is why it is bad practice to return something or to throw an Exception from a finally.
Why are you catching that Exception? I hope it is only so you can see what happens if you catch it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!