The following benefits of using the Optionally class are highlighted:
It avoids null tests by encapsulating optional data, such as null or not-null values, resulting in better, more readable, and more reliable code. It serves as an object wrapper and returns an object rather than a value, which can be utilised to prevent run-time errors. NullPointerExceptions