Question: Which lambdas can replace the method references in this code? (Choose two.) A. x.length() B. x -> x.length() C. x -> x::length D. System.out.println(s) E.

Which lambdas can replace the method references in this code? (Choose two.) 

Stream.of("fish", "mammal", "amphibian") .map (String:: length) .findFirst() .ifPresent (System.out::println);

A. x.length()

B. x -> x.length()

C. x -> x::length

D. System.out.println(s)

E. s -> System.out.println(s)

F. s -> System.out::println

Stream.of("fish", "mammal", "amphibian") .map (String:: length) .findFirst() .ifPresent (System.out::println);

Step by Step Solution

3.41 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The code snippet provided is using two method references in Javas Stream API Stringlength and System... 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!