From the course: Advanced Java: Hands-on with Streams, Lambda Expressions, Collections, Generics and More

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Streams API and handling data sets

Streams API and handling data sets

- The Stream API allows us to process and manipulate datasets using a functional programming approach and it can simplify our code when handling datasets. Let's start with Streams. What are these? A Stream is a sequence of elements that can be processed sequentially or in parallel. Streams have a source. They can be created in various ways using a Stream API. You can create a Stream from various sources such as collections, arrays, or I/O channels. Here are some examples. On line 12, I created a Stream using the list I created on line 11. I can simply do this with the .stream() method. I can also create a Stream from an array. This is a slightly different approach. You can see in line 15, I'm creating an array and then on line 16, I'm using the .stream() method on the arrays helper class to actually turn this into a Stream. And I can also create a Stream with the Stream.of method that I'm using online 19. There's…

Contents