Optional in Java
Published in
1 min readMar 15, 2020
A colleague of mine once said:
“The more I read about Optional, the more I like it.”
And another colleague of mine said:
“Optional initiative is overwhelming. You should give some space to us.”
So apparently, a small dose of Optional is easier to digest than one long tutorial. So here we go!
- Use Optional when a method returns
null
: Talks about different ways in which Optional can be used while calling a method that can potentially return anull
value. - Deprecating @Nonnull and @Nullable annotations : Shows why these annotations are no longer needed after the introduction of Optional in Java 8.