943,696 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 671
  • Java RSS
Feb 28th, 2008
0

More Excptions

Expand Post »
I just want to know what happens when this code is written:
public static void main(String[] args) throws IOException
Reputation Points: 9
Solved Threads: 1
Light Poster
Parsu7 is offline Offline
29 posts
since Feb 2008
Feb 28th, 2008
0

Re: More Excptions

You will not be obligated to write something like:
Java Syntax (Toggle Plain Text)
  1. try {
  2.  
  3. } catch(IOException io) {
  4.  
  5. }
in your code. Meaning that if a method throws an IOException you will not have to catch it but if it is thrown there will be no place for the exception to "go" since nothing calls main(), so the program will end with exception.
Sponsor
Featured Poster
Reputation Points: 1014
Solved Threads: 446
Nearly a Senior Poster
javaAddict is offline Offline
3,258 posts
since Dec 2007
Feb 28th, 2008
0

Re: More Excptions

And for that reason, you shouldn't ever throw exceptions from main().
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 838
Posting Genius
Ezzaral is offline Offline
6,757 posts
since May 2007
Feb 29th, 2008
0

Re: More Excptions

Thank you.
Reputation Points: 9
Solved Threads: 1
Light Poster
Parsu7 is offline Offline
29 posts
since Feb 2008
Feb 29th, 2008
0

Re: More Excptions

Click to Expand / Collapse  Quote originally posted by javaAddict ...
You will not be obligated to write something like:
Java Syntax (Toggle Plain Text)
  1. try {
  2.  
  3. } catch(IOException io) {
  4.  
  5. }
in your code. Meaning that if a method throws an IOException you will not have to catch it but if it is thrown there will be no place for the exception to "go" since nothing calls main(), so the program will end with exception.
Thank you.
Reputation Points: 9
Solved Threads: 1
Light Poster
Parsu7 is offline Offline
29 posts
since Feb 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Windows authentication using java
Next Thread in Java Forum Timeline: Replace occurrences in a string





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC