Optional
is documented as:
An immutable object that may contain a non-null reference to another object. Each instance of this type either contains a non-null reference, or contains nothing (in which case we say that the reference is "absent"); it is never said to "contain
null
".
Can you help with an example of the usefulness of the Optional
class? when might I use it as opposed to something else?