ifPresentOrElse
The `ifPresentOrElse` method is a terminal operation available on `Optional` objects in Java, introduced in Java 11. It provides a concise way to execute one of two actions based on whether the `Optional` contains a value.
The `ifPresentOrElse` method accepts two arguments: a `Consumer` for the action to perform if the `Optional` has
This method is useful for handling cases where you need to perform a specific action when a
For example, if you have an `Optional<String>` named `name`, you could use `name.ifPresentOrElse(System.out::println, () -> System.out.println("No name provided"));`.