[Solved] Stream Error: stream has already been operated upon or closed

public class StreamTest {
    public static void main(String[] args) {
        //Generate a Stream of type String
        Stream<String> stringStream = Stream.of("1", "2", "3", "4", "5");
        // Convert string type in stream to int type using map method
        stringStream.map(
                (String s) ->{
                    return Integer.parseInt(s);
                });
        stringStream.forEach(i -> System.out.println(i));
    }
}

As shown in the figure, the code runs with an error:

The stream has been used or closed

This is a feature of streams: a stream can only be used once!

Read More: