Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

new problem on try-catch

 
deepesh mathur
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in a recent post i've learned that there is no method to prevent finally block to be executed but one of my teachers told me that it is possible by using :
System.in(0);
(in the try block)
really confused please help...
 
Bert Bates
author
Sheriff
Posts: 8898
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this strange, corner-case of a topic is NOT on the exam - relax!
 
Kelvin Chenhao Lim
Ranch Hand
Posts: 513
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm pretty sure your teacher meant "System.exit(0)" instead of "System.in(0)". The latter is invalid syntax. As far as I know, invoking System.exit() is the only way to stop a finally block from being executed--and that's because System.exit() immediately terminates all threads and shuts down the JVM. This isn't really a corner case, but it's an extremely bad practice (to say the least).
 
deepesh mathur
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so it's not a matter of real concern..
thanks everyone..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic