Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the definition of unchecked exception in the error-handling exercise instructions #2814

Merged
merged 2 commits into from
Aug 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.