Computer Science Canada try-catch-finally |
Author: | Martin [ Thu Oct 13, 2005 9:42 pm ] | ||
Post subject: | try-catch-finally | ||
Quick question. What's the difference between #1 and #2:
Thanks in advance. |
Author: | wtd [ Thu Oct 13, 2005 9:52 pm ] |
Post subject: | |
What happens if an exception other than SomeException is thrown? The first example will run baz. The latter won't. |
Author: | Martin [ Thu Oct 13, 2005 10:18 pm ] |
Post subject: | |
Ahh, got it. Thanks. |
Author: | Finaltank [ Fri Oct 14, 2005 3:26 pm ] | ||
Post subject: | |||
What about interrupted exception?
|
Author: | Hikaru79 [ Fri Oct 14, 2005 4:27 pm ] |
Post subject: | |
InterruptedException is just a subclass of Exception. You can catch exceptions specifically (like in your example) so that you can deal with different exceptions in different ways, or you can catch a generic "Exception" which handles any subclasses of Exception (most of them). |