// "Collapse loop with stream 'forEach()'" "true-preview" import java.util.*; public class Collect { class Person { String getName() { return ""; } } final Set names = new HashSet<>(); void collectNames(List persons){ persons.stream().map(Person::getName).forEach(names::add); } }