| Author |
try catch finally
|
kiruthiga arumugam
Greenhorn
Joined: Sep 29, 2008
Posts: 8
|
|
hi to all try{ .... System.exit(0); } catch(){//code ABC} will this code ABC execute??
|
 |
marc weber
Sheriff
Joined: Aug 31, 2004
Posts: 11343
|
|
If only there were some way to test that... Do you have javac installed on your computer?
|
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
|
 |
Pramod P Deore
Ranch Hand
Joined: Jul 15, 2008
Posts: 629
|
|
I don't think the code in the catch() block will be excuted. beacause after System.exit(0) the program will be terminated...
|
Life is easy because we write the source code.....
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16681
|
|
Originally posted by pramod deodeore: I don't think the code in the catch() block will be excuted. beacause after System.exit(0) the program will be terminated...
The problem with the example is the "...." could be anything. How do you know that that section of code won't throw an exception? Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32611
|
|
Are you sure about the bit saying catch() { What is in the ()?
|
 |
Kaydell Leavitt
Ranch Hand
Joined: Nov 18, 2006
Posts: 679
|
|
Doesn't the following code not only exit the currently running program but also exits the entire JVM that the program is running in so that if there are other programs running in the same JVM that they get terminated too? System.exit(0); If System.exit() does exit the whole JVM what is the proper way to terminate only the current application? You can't throw an unchecked exception because that would only terminate the currently running thread, right? [ October 11, 2008: Message edited by: Kaydell Leavitt ]
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32611
|
|
|
I think you are right, but we haven't heard how Kiruthiga Arumugam got the class to run.
|
 |
 |
|
|
subject: try catch finally
|
|
|