- Exception class has 5 constructors
empty constructor
constructor accepting string message
constructor accepting string message and throwable
constructor accepting throwable
constructor accepting string message, throwable, boolean (enableSuprresion), boolean (writableStackTrace) - Autoclosable
It is an interface
It has abstract public void close method that throws Exception.
You have to overried close method properly, overriden close method may not throw an exception.
if overriden close method throws an exception, then try with resource block should handle that exception or enclosing method should use throw clause.
when more than one resources are in try() block, they are closed in reversed order than how they are declared.
if both try and close block throw an exception then one thrown by close block is suppressed. - try with resource
try () {}
; separated multiple lines are allowed in try () block. Last line need not have semicolon in the end.
all the variables in try () block must be final or effectively final. - RuntimeException extends from Exception
But if class extends Exception then that becomes a checked exception
IOException is checked exception
IllegalStateException is unchecked exception - Throwable and Error are not recommended to catch