Although technically a RuntimeException such as NullPointerException is the same as checked exceptions such as IOException, their philosophy is very different. In short, checked exceptions there allow you to solve problems that are beyond the control of programmers, such as network crashes or missing files. The intended use of excluded exceptions is to catch programming errors.
Given that they exist to catch programming errors, a NullPointerException and other unchecked exceptions should almost never be caught. Instead, a programming error should be fixed that allowed them to be thrown.
source
share