I am making a program that converts pictures to a grayscale form and from that grayscale form it converts it to a fairey format.
I am using nested for-loops to convert a nested list. This works perfectly but I want to do it using streams and if I do it using that the output changes, but I think it should result in the same output. Where am I wrong?
grayPhoto is a List<List<Graypixel>>
Do any of you see what I'm doing wrong or how the stream should be?
for (int i = 0; i < grayPhoto.size(); i++) {
for (int j = 0; j < grayPhoto.get(i).size(); j++) {
numbersSet.add(grayPhoto.get(i).get(j));
}
}
grayPhoto.forEach(r -> r.forEach(e -> numbersSet.add(e)));