The Problem Optional Solves NullPointerException is the most common runtime exception in Java, and it is almost always avoidable. Optional<T> is not a magic fix — used incorrectly it becomes a more verbose null check. Used correctly, it encodes the possibility of absence directly in the type system, so callers can never “forget” to handle the empty case. This article covers both how to use Optional and — critically — how not to.
Continue reading »Nullpointerexception
1 post in this section