Question PRG-JAVA-0078
HardWhat does Optional.orElse(compute()) do differently from orElseGet(() -> compute())?
- A.
They are identical
- B.
orElse never calls it
- C.
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Java question
What does Optional.orElse(compute()) do differently from orElseGet(() -> compute())?
They are identical
orElse never calls it
Sign up free to see the answer and a step-by-step explanation.
orElseGet always calls it
orElse always calls compute(); orElseGet calls it only when the Optional is empty