LANGUAGE/!$%!% ERROR NOTE 2020. 3. 3. 02:42

Java 8+

1. Error - 오류

java.lang.IllegalStateException: stream has already been operated upon or closed 

at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:229) 
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) 
at StreamAPI.map(StreamAPI.java:104) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:498)

2. Problemn - 문제

Stream을 두번 호출했을 때 문제가 발생한다.

Stream API는 한번만 호출할 수 있게 설계되어있다.

3. Solved - 해결

Stream은 매번 새로 만들어 써야한다!

4. Reference - 참조

https://www.baeldung.com/java-stream-operated-upon-or-closed-exception
https://brocess.tistory.com/152