By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,032 Members | 825 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,032 IT Pros & Developers. It's quick & easy.

Exceptions terminate Program?

P: n/a
Quick question, does exceptions in Java by default terminate the main
program?

Thanks,

--
Al
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Al Wilkerson" <ac***@comcast.net> wrote in message news:<03oNb.56106$nt4.86764@attbi_s51>...
Quick question, does exceptions in Java by default terminate the main
program?

Thanks,


Quick answer, no.

You are welcome.
Jul 17 '05 #2

P: n/a

"Al Wilkerson" <ac***@comcast.net> wrote in message
news:03oNb.56106$nt4.86764@attbi_s51...

Quick question, does exceptions in Java by default
terminate the main program?


You might want to try it and see for yourself ;) !

Try this code:

public class WillCrash
{
public static void main(String[] args)
{
String s = null;
System.out.println("Length of 's' is" + s.length());
}
}

Programming is, above all, a *practical* art, so don't be afraid to
experiment !

I hope this helps.

Anthony Borla
Jul 17 '05 #3

P: n/a
"Al Wilkerson" <ac***@comcast.net> wrote in message news:<03oNb.56106$nt4.86764@attbi_s51>...
Quick question, does exceptions in Java by default terminate the main
program?

Thanks,

As you experienced it. Try-catch does exists for giving you
some control upon Exception.
Jul 17 '05 #4

P: n/a
Yea, I realize that I needed to catch the exception in the class I was in,
instead of letting it proprogate back up to main(), which is in another
file.
Because if it's only caught in the main() method then it will terminate.

Thanks,

Al
"hiwa" <HG******@nifty.ne.jp> wrote in message
news:68**************************@posting.google.c om...
"Al Wilkerson" <ac***@comcast.net> wrote in message

news:<03oNb.56106$nt4.86764@attbi_s51>...
Quick question, does exceptions in Java by default terminate the main
program?

Thanks,

As you experienced it. Try-catch does exists for giving you
some control upon Exception.

Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.