Which code fragment must be inserted at line n1 to enab…

Given the code fragment:
List<Integer> nums = Arrays.asList (10, 20, 8):
System.out.println (
//line n1
);
Which code fragment must be inserted at line n1 to enable the code to print the maximum number in the
nums list?

Given the code fragment:
List<Integer> nums = Arrays.asList (10, 20, 8):
System.out.println (
//line n1
);
Which code fragment must be inserted at line n1 to enable the code to print the maximum number in the
nums list?

A.
nums.stream().max(Comparator.comparing(a -> a)).get()

B.
nums.stream().max(Integer : : max).get()

C.
nums.stream().max()

D.
nums.stream().map(a -> a).max()



Leave a Reply 4

Your email address will not be published. Required fields are marked *


andrei

andrei

A
Only A and B compile, still, just A is returning the max value.