954,141 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

More Excptions

I just want to know what happens when this code is written:
public static void main(String[] args) throws IOException

Parsu7
Light Poster
29 posts since Feb 2008
Reputation Points: 9
Solved Threads: 1
 

You will not be obligated to write something like:

try {

} catch(IOException io) {

}

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.

javaAddict
Nearly a Senior Poster
Team Colleague
3,329 posts since Dec 2007
Reputation Points: 1,014
Solved Threads: 448
 

And for that reason, you shouldn't ever throw exceptions from main().

Ezzaral
Posting Genius
Moderator
15,985 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
 

Thank you.

Parsu7
Light Poster
29 posts since Feb 2008
Reputation Points: 9
Solved Threads: 1
 

You will not be obligated to write something like:

try {

} catch(IOException io) {

}

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.

Parsu7
Light Poster
29 posts since Feb 2008
Reputation Points: 9
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You