Skip to content

Commit

Permalink
Fix the definition of unchecked exception in the error-handling exerc…
Browse files Browse the repository at this point in the history
…ise instructions (#2814)

* Clarify the meaning of unchecked exceptions in the documentation

* Also fix a grammar error in the error-handling exercise instructions
  • Loading branch information
rkabhishek authored Aug 24, 2024
1 parent 18ff81d commit 85e331f
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This is because checked exceptions are meant to be handled at runtime, i.e. they

They're often used when a method can't return any valid result, for example a search method which hasn't found the item it was searching for.

It's an alternative to returning null or a error code. A checked exception is better than those alternatives because it forces the user of the method to consider the error case.
It's an alternative to returning null or an error code. A checked exception is better than those alternatives because it forces the user of the method to consider the error case.

## Unchecked exceptions

Expand All @@ -34,4 +34,4 @@ You don't have to declare them in the [method signature](https://docs.oracle.com

### Examples of where they are used

Unchecked exceptions are mean to be used for any error than can't be handled at runtime, e.g. running out of memory.
Unchecked exceptions are typically caused by defects in the program and can be prevented by proper coding. Example: ArrayIndexOutOfBoundsException can be prevented by ensuring that the array indices are between 0 and the array's length.

0 comments on commit 85e331f

Please sign in to comment.