Task task0908 Exception while working with strings: As i understood from the lesson 4 we handle exceptions in either throw clause (here: public static void main(String[] args) throws Exception) or
with try-catch block. Why we have both in this example? thank you
Why we have both: the throws clause in main method and try-catch block?
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Guadalupe Gagnon
14 November 2019, 16:51
Catch blocks will catch and allow you to handle exceptions within the code. Throw says that when an uncaught exception happens that the code in that block will stop and the method will throw an exception. This will either pass it along to be caught in another part of the code or crash the program if uncaught.
0