Question: Fill in the blanks so that both methods produce the same output for all inputs. A. isNotNull, isPresent B. ifPresent, isPresent C. isPresent, forEach D.
Fill in the blanks so that both methods produce the same output for all inputs.

A. isNotNull, isPresent
B. ifPresent, isPresent
C. isPresent, forEach
D. isPresent, ifPresent
E. None of the above.
private static void longer (Optional opt) { if (opt.()) System.out.println("run: " + opt.get()); } private static void shorter (Optional opt) { opt.map(x-> "run: " + x) (System.out::println); }
Step by Step Solution
3.38 Rating (164 Votes )
There are 3 Steps involved in it
The code snippets are dealing with an Optional in Java and we are asked to find the correct method c... View full answer
Get step-by-step solutions from verified subject matter experts
