Let’s say we have a collection; it could be a list or set, it doesn’t really matter as long as it is a collection, and we want to iterate over it. Often, we make this mistake: we immediately open stream whenever we think of working with a collection; since java 8, it has, sort of, become our second nature, which is excellent. Hurray!
However, I have seen this in many production codes. Well, the outcome indeed serves our purpose, but it may not be necessary to open a stream. All the collection interface has a for each method in them, and it does the same thing we are supposed to do here. However, creating a stream creates a new object that is just needed to get our desired output.
#java8, #stream #java #stream #forEach #iteration
Nesta página do site você pode assistir ao vídeo on-line Avoid using stream for simple iteration duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário A N M Bazlur Rahman 04 Março 2022, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 318 vezes e gostou 15 espectadores. Boa visualização!