You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: concepts/exceptions/introduction.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,8 @@ An exception is an event that occurs during the execution of a program that disr
8
8
Exceptions are raised explicitly in Java, and the act of raising an exception is called _throwing an exception_.
9
9
The act of handling an exception is called _catching an exception_.
10
10
11
+
In Java, all exceptions are subclasses of the `Exception` class, which itself is a subclass of `Throwable`.
12
+
11
13
Java distinguishes two types of exceptions:
12
14
13
15
1. Checked exceptions
@@ -20,7 +22,7 @@ An example of a checked exception is the `FileNotFoundException` which occurs wh
20
22
21
23
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.
22
24
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`.
24
26
25
27
### Unchecked exceptions
26
28
@@ -29,7 +31,7 @@ An example of an unchecked exception is the `NullPointerException` which occurs
29
31
30
32
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.
31
33
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`.
0 commit comments