Optional is a new type introduced in Java 8. It is used to represent a value that may or may not be present. In other words, an Optional object can either contain a non-null value (in which case it is considered present) or it can contain no value at all (in which case it is considered empty).
An Optional object can have one of the following possible states:
Present: The Optional object does not represent absence. A value is in the Optional object and it can be accessed by invoking get().
Absent: The Optional object does represent the absence of a value; you cannot access its content with get().
Usage of the index in java? Advantages a