Type a filter-map-count pipeline on a list
Type a filter-map-count pipeline on a list
Answer
long n = names.stream() .filter(s -> s.length() > 3) .map(String::toLowerCase) .count();
Nothing runs until count() is called. filter and map are lazy registrations. count() triggers the pipeline and returns the number of elements that passed filter.