Is it true that since Java 1.8 returning Optional
object is more preferable than throwing an exception?
Increasingly i see the code like this:
p
In situations where errors might arise, a suitable datatype is Try.
Instead of using the abstractions 'present' or 'empty', a Try uses the abstractions 'failure' or 'success'.
As Try is not provided by Java 8 out of the box, it is necessary to use some 3. party library. (Maybe we will see it added in Java 9?)
Try for Java