From the course: Java: Lambdas and Streams
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Advanced streams operations - Java Tutorial
From the course: Java: Lambdas and Streams
Advanced streams operations
- [Speaker] So now we've covered the most common uses of streams. Let's take a look at some slightly more advanced features and concepts. So let's find out a bit more about how streams work. So I've got this stream here where I'm applying lots of operations to my stream. So I'm sourcing it, I'm mapping the items to uppercase. I'm filtering it so there's only items beginning with P. And then I'm printing them all out. So if I run this now, I just get pasta and pineapple in capital letters. Now let's say at some point later on, I want to print it out again. So underneath my stream, let's say I do shoppingList.Stream and I do forEach. And then again, I'm going to do item arrow System.out.println and pass in item. So I'm going to run this again. And this time I get an exception. Specifically, an illegal states exception. And it says that the stream has already been operated upon or closed. This is because streams can…