Given the code fragment:
What is the result?
Given the code fragment:
What is the result?
E
C,tested
Answer C. Tested
C. code: public static void main (String[] args) throws InterruptedException, ExecutionException { List<String> li = Arrays.asList("pen", "a", "pencil"); Predicate<String> test = s -> { int i = 0; boolean result = s.contains("pen"); System.out.print(i++ + ":"); return result; }; li.stream().filter(test).findFirst().ifPresent(System.out::println); }
C,tested
C, Tested.
list.contains("string") is end first index.
C is correct after fixing typos.