-
Closeable (Java 5) throws IOException
AutoCloseable (Java 7) throws Exception - Closeable extends AutoCloseable.
-
try-with-resources : close when get out of the try block in reverse order. -
If more than one exception is thrown in a try-with-resources block
All later exception will be added as suppressed. -
try {
}catch(Exception 1 | Exception 2 e) {
}
There should be no subclass relationship between Exception 1 and Exception 2. Do not assign a new value to "e" in multi-catch. -
If exception throws in catch block or finally block, no suppressions happen.
The last exception thrown get sent to the caller. - If a method throws a exception in the declaration, it must be included in try catch block. Even if it is in the finally block.
- Try-with-resource Object must not have close method if that Object is declared in Try block.
Wednesday, March 4, 2015
OCPJP7 Exception Handling
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment