unchecked exception in java

https://‮ual.www‬tturi.com
unchecked exception in java

An unchecked exception in Java is an exception that is not checked by the compiler at compile-time. This means that the code does not have to handle or declare the exception, and the exception can be thrown at any point in the program without being caught.

Unchecked exceptions are also known as runtime exceptions, as they are typically thrown at runtime rather than during compilation. Examples of unchecked exceptions include NullPointerException, ArrayIndexOutOfBoundsException, and IllegalArgumentException.

In contrast, checked exceptions are exceptions that are checked by the compiler at compile-time. This means that the code must either handle or declare the exception, or the compiler will generate an error. Checked exceptions are typically used to indicate recoverable conditions that a program can catch and handle, such as input/output errors or network failures. Examples of checked exceptions include IOException and SQLException.

It is generally recommended to use checked exceptions for recoverable conditions and unchecked exceptions for programming errors that cannot be handled by the program. This allows the program to handle recoverable errors gracefully, while still allowing the program to fail fast when an unrecoverable error occurs.

Created Time:2017-10-17 22:51:24  Author:lautturi