What is the output of the following?
Stream<String> s = Stream.of("Atlanta", "Chicago", "New York"); long count = s.filter(c -> c.startsWith("C")).count(); System.out.print(count);
A.
In streams, the filter()
method filters out any values that do not match.
This means the only value to make it to the terminal operator count()
is Chicago, and Option A is correct.