How can I achieve the same logic in my code using only Streams, without the for loop as shown in my code below?
I have tried using flatMap, but I get stuck on the condition part, since allMatch() only returns a boolean.
How can I retrieve all the rows from the nested ArrayList that passes the condition without using for loop?
ArrayList<ArrayList<Tile>> completeRows = new ArrayList<>();
for (ArrayList<Tile> rows: getGridTiles()) {
if (rows.stream().allMatch(p -> p.getOccupiedBlockType() != BlockType.EMPTY)) {
completeRows.add(rows);
}
}