Although Java streams were designed to be operated only once, programmers still ask how to reuse a stream. From a simple web search, we can find many posts with this same issue asked in many different ways: "Is there any way to reuse a Stream in java 8?", "Copy a stream to avoid stream has already been operated upon or closed", "Java 8 Stream IllegalStateException", and others.
Hence, if we want to traverse a Stream<T>
multiple times, then either we have to:
Laisser un commentaire
Participez-vous à la discussion?N'hésitez pas à contribuer!