Java 8 Optional - Replace your get() calls | Reverse Coding
Optional class were introduced in order to prevent NullPointerException
, but method get()
used to retrieve the value inside the Optional
might still throw a NoSuchElementException
.
Different name, same issue?
Calling get()
without checking that the value is actually present it's a problem. So we should always write something like this in order to use get()
.
Read full article from Java 8 Optional - Replace your get() calls | Reverse Coding
No comments:
Post a Comment