[Java8 new features 5] Stream

1. Introduction

Stream is a key abstract concept for processing collections in Java 8. It can specify the operations you want to perform on the collection, and can perform very complex operations such as searching, filtering, and mapping data. Using Stream API to manipulate collection data is similar to using SQL to perform database queries. You can also use the Stream API to perform operations in parallel. In short, the Stream API provides an efficient and easy-to-use way of processing data.

Features:

        1. It is not a data structure and will not save data.

        2. The original data source will not be modified, it will save the data after the operation to another object. (Reserved opinion: after all, the peek method can modify the elements in the stream)

        3. Lazy evaluation. In the intermediate processing process, the stream only records the operation, and will not execute it immediately. The actual calculation will not be performed until the termination operation is executed.

Two, code examples

1. Get the specified list operation

2. Stream operations to read files

 

A long way to go: https://blog.csdn.net/mu_wind/article/details/109516995

Guess you like

Origin blog.csdn.net/guorui_java/article/details/109758558