Which statement is true about java.util.stream.Stream?
Which statement is true about java.util.stream.Stream?
A stream cannot be consumed more than once. Once a terminal operation is performed on a stream, it becomes exhausted and cannot be used again. Attempting to reuse the stream after it has been consumed will result in an IllegalStateException.
Answer is A
After the terminal operation is performed, the stream pipeline is considered consumed, and can no longer be used. For Intermediate operations,they always return a new stream
Answer is A
A and E are correct.
A is the answer
A is true as exception is thrown if same stream is used after terminal operation is run on it.
The answer is letter A, a stream can only be consumed once. Regarding the letter E, it is false, pay attention that the statement talks about the stream parameter and not the method parameter, you cannot use a lambda expression as a stream parameter, it is a trick.
A & E are correct!
A is NOT. Can use peak() consumed more than one. Answer is B. Because can change parallel stream to change mode.
No, the "peek()" method is an intermediate operation
stream takes no parameter, so E is incorrect.
Is E correct?