Home >Java >javaTutorial >What is the use of Stream in Java?

What is the use of Stream in Java?

PHPz
PHPzforward
2023-04-28 21:16:051701browse

Description

1. Java 8 API adds a new abstraction called Stream, which allows you to process data using declarations.

2. Stream uses SQL statements to query data from the database in an intuitive way, providing high-level abstraction for Java set operations and performance.

3. The tream API can greatly improve the productivity of Java programmers, allowing programmers to write efficient, clean, and concise code.

Stream (stream) is a queue from a data source that supports aggregation operations.

Examples

List<Integer> transactionsIds =
widgets.stream()
             .filter(b -> b.getColor() == RED)
             .sorted((x,y) -> x.getWeight() - y.getWeight())
             .mapToInt(Widget::getWeight)
             .sum();

What collection classes are there in Java

Collections in Java are mainly divided into four categories:

1, List List: ordered, repeatable;

2, Queue queue: ordered, repeatable;

3, Set collection: non-repeatable;

4, Map mapping: unordered, unique keys, non-unique values.

The above is the detailed content of What is the use of Stream in Java?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete