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

20 lines
467 B
Java

// "Collapse loop with stream 'collect()'" "true-preview"
import java.util.*;
import java.util.stream.Collectors;
public class Collect {
class Person {
String getName() {
return "";
}
}
void collectNames(List<Person> persons){
Set<String> names = new HashSet<>(), other = new HashSet<>();
if(persons != null) {
names = persons.stream().map(Person::getName).collect(Collectors.toSet());
}
System.out.println(names);
}
}