aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes new problem on try-catch Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "new problem on try-catch" Watch "new problem on try-catch" New topic
Author

new problem on try-catch

deepesh mathur
Ranch Hand

Joined: Aug 13, 2007
Posts: 39
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

Joined: Oct 14, 2002
Posts: 8883
    
    5
this strange, corner-case of a topic is NOT on the exam - relax!


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Kelvin Chenhao Lim
Ranch Hand

Joined: Oct 20, 2007
Posts: 513
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).


SCJP 5.0
deepesh mathur
Ranch Hand

Joined: Aug 13, 2007
Posts: 39
so it's not a matter of real concern..
thanks everyone..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: new problem on try-catch