Counting words

Report a typo

Select all correct ways to count the number of occurrences of targetWord in the list of strings words ignoring the case.

a)

words.stream()
             .filter(w -> w.equals(targetWord.toUpperCase()))
             .count();

b)

words.stream()
             .filter(w -> w.equalsIgnoreCase(targetWord))
             .count();

c)

words.stream()
             .filter(w -> w.equals(targetWord.toUpperCase()))
             .map(w -> w.toUpperCase())
             .count();

d)

words.stream()
             .map(w -> w.toUpperCase())
             .filter(w -> w.equals(targetWord.toUpperCase()))
             .count();

e)

words.stream()
             .filter(w -> w.equalsIgnoreCase(targetWord))
             .map(w -> 1L)
             .reduce(0L, (count, next) -> count + 1);
Select one or more options from the list
___

Create a free account to access the full topic