mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-31 02:50:55 +07:00
13 lines
428 B
Java
13 lines
428 B
Java
// "Collapse loop with stream 'findFirst()'" "true-preview"
|
|
|
|
import java.util.*;
|
|
|
|
public class Main {
|
|
public Integer[] testFindFirstIfPresent(List<List<String>> data) {
|
|
List<Integer> result = new ArrayList<>();
|
|
for (List<String> list : data) {
|
|
list.stream().filter(str -> !str.isEmpty()).findFirst().ifPresent(str -> result.add(str.length()));
|
|
}
|
|
return result.toArray(new Integer[result.size()]);
|
|
}
|
|
} |