I've read the answers to this question about the difference between Optional.orElse()
and Optional.orElseGet()
.
It seems that orElseGet()
is always more efficient than orElse()
because of lazy evaluation, and it's apparently visible even when benchmarking very simple examples like this one (see part 4): https://www.baeldung.com/java-optional-or-else-vs-or-else-get
So, are there any use cases where it's better to use orElse
rather than orElseGet
?