Avoid using stream for simple iteration

Publicado el: 04 marzo 2022
en el canal de: A N M Bazlur Rahman
318
15

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


En esta página del sitio puede ver el video en línea Avoid using stream for simple iteration de Duración hora minuto segunda en buena calidad , que subió el usuario A N M Bazlur Rahman 04 marzo 2022, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 318 veces y le gustó 15 a los espectadores. Disfruta viendo!