Exam 1z0-816 All QuestionsBrowse all questions from this exam
Question 9

Given:

var fruits = List.of(“apple”, “orange”, “banana”, “lemon”);

You want to examine the first element that contains the character n.

Which statement will accomplish this?

    Correct Answer: C

    To examine the first element that contains the character 'n', you should use the stream method 'findFirst()' after filtering elements that contain 'n'. This returns an Optional containing the first occurrence that matches the condition or an empty Optional if no such element is found.

Discussion
yuu_oppaiOption: C

The correct answer is C