OptionaloptionalString = Optional.ofNullable("Hello"); System.out.println(optionalString.get()); // prints "Hello"
OptionalIn this example, we create an empty Optional object. We then use the `orElse()` method to provide a default value in case the Optional does not contain a value. Since the Optional is empty, it will return the default value "Hello". The com.google.common.base Optional package is part of the Google Guava library, which provides a set of utility classes and methods for use in Java projects.optionalString = Optional.empty(); System.out.println(optionalString.orElse("Hello")); // prints "Hello"