SE450: Java: Exceptions [3/41] Previous pageContentsNext page

Exception basics

Checked vs. Unchecked

Error, Exception, RuntimeException

throw

try, catch, finally

Checked exceptions are checked by the compiler so that your method should only throw exceptions declared to be thrown. A checked exception extends Exception.

Unchecked exceptions extend RuntimeException and Error, meaning the compiler will allow them to be thrown by any method.

Officially, you are supposed to only create checked exceptions, but there are arguments against this. You can throw an Error or a RuntimeException without adding a throws clause. There are a number of these already available in the java APIs.

Previous pageContentsNext page