Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/collect/afterCollectHashSetFieldInitializer.java
2022-12-23 13:26:29 +00:00

16 lines
329 B
Java

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