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.

More streams operations

More streams operations - Java Tutorial

From the course: Java: Lambdas and Streams

More streams operations

- [Narrator] So now I've got my shopping list, and I'm sorting the items alphabetically and printing out the results using Streams. So now, let's see what other cool things I can do with the Streams API. Let's say I want to make everything in my shopping list be written in capital letters. The Streams API has a method called map, which I can use to do this. So I'm not going to put this map method, so I'm not going to put app method at the end of this chain of methods here on my Stream. For each has to go last because it's a terminal method. So no methods can go after that. But sorted is an intermediate method, and so is map. So I can put these anywhere before there for each. So I'm going to put it after the sorted one. And I'm going to put it on a new line just because I think it's a bit more readable, because it doesn't have to be on a new line. So I'm going to do .map. And this map method takes a function as an argument.…

Contents