| 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: 8717
|
|
this strange, corner-case of a topic is NOT on the exam - relax!
|
Eliminate fossil fuel subsidies. (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..
|
 |
 |
|
|
subject: new problem on try-catch
|
|
|