Skip to content

Commit 88297ef

Browse files
committed
Clarify exception hierarchy and definitions in introduction
1 parent d3e76c6 commit 88297ef

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

concepts/exceptions/introduction.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ An exception is an event that occurs during the execution of a program that disr
88
Exceptions are raised explicitly in Java, and the act of raising an exception is called _throwing an exception_.
99
The act of handling an exception is called _catching an exception_.
1010

11+
In Java, all exceptions are subclasses of the `Exception` class, which itself is a subclass of `Throwable`.
12+
1113
Java distinguishes two types of exceptions:
1214

1315
1. Checked exceptions
@@ -20,7 +22,7 @@ An example of a checked exception is the `FileNotFoundException` which occurs wh
2022

2123
This type of exception is checked at compile-time: methods that throw checked exceptions should specify this in their method signature, and code calling a method that might throw a checked exception is required to handle it or the code will not compile.
2224

23-
All exceptions in Java that do not inherit from `RuntimeException` are checked exceptions.
25+
All checked exceptions are subclasses of `Exception` that do not extend `RuntimeException`.
2426

2527
### Unchecked exceptions
2628

@@ -29,7 +31,7 @@ An example of an unchecked exception is the `NullPointerException` which occurs
2931

3032
This type of exception is not checked at compile-time: methods that throw unchecked exceptions are not required to specify this in their method signature, and code calling a method that might throw an unchecked exception is not required to handle it.
3133

32-
All exceptions in Java that inherit from `RuntimeException` are unchecked exceptions.
34+
All unchecked exceptions inherit from `RuntimeException`, which itself is an extension of `Exception`.
3335

3436
## Errors
3537

0 commit comments

Comments
 (0)