I have a for loop iterating over a Integer [][]map.
Currently is like this:
for(int i = 0; i < rows; i++) {
for(int j = 0; j < columns; j++) {
if(map[i][j] == 1)
q.add(new Point(i,j));
}
}
Instead of 2d array, suppose I have List<List<Integer>> maps2d.
How would I do that with streams?
So far I got this:
maps2d.stream()
.forEach(maps1d -> maps1d.stream()
.filter(u -> u == 1)
.forEach(u -> {
}
)
);
Is it correct so far?
If yes, how do I count i and j in order to create the new Point(i,j) and add it to q ?