Optional in orElse-Branch throws Exception [duplicate]
问题 This question already has an answer here : Java 8's orElse not working as expected (1 answer) Closed 3 years ago . So I'm working with Optionals and came across a strange behaviour. I want to know if this is really an intendet "feature" or something...odd... Here is the given example: I've got a method with an Optional in whose orElse I want to evaluate an other optional. If the other Optional is not present, I'll raise an IllegalArgumentException: firstOptionalVar.orElse(secondOptionalVar