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. 

private static void longer (Optional opt) { if (opt.()) System.out.println("run: " +

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

1 Expert Approved Answer
Step: 1 Unlock

The code snippets are dealing with an Optional in Java and we are asked to find the correct method c... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Oracle Questions!