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?
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?
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.
The correct answer is C