Atitit Java LINQ and the stream API comparison

Source: Internet
Author: User
Tags stream api

Atitit Java LINQ and the stream API comparison

1.1. Linq and Stream APIs, and key pros and cons 1

Scenario 1 for 1.2. LINQ and Stream APIs

LINQ 1 in 1.3. java

LINQ comes from SQL, and we know that SQL is a standardized DSL in the field of data querying. 1.1. the relationship between Linq and Stream APIs, as well as major pros and cons

Stream is more generic, LINQ is more single-minded, focus on the DSL of data query. LINQ is a specialized stream.

In addition, LINQ is more DSL, more convenient and concise.

The stream is somewhat more flexible than the bottom, but a little long-winded.

1.2. Linq and Stream API scenarios

LINQ is more useful in most situations, after all, SQL is a standardized data query DSL API.

But in a few cases, a simple query of a list, it may be a bit verbose LINQ, the stream will be more concise.

In addition, the use of stream will be much better in the field of non-data queries. LINQ in 1.3. Java

The Java JDK does not implement the LINQ API by default. Can only be implemented by a third party class library.

Although Java has a linq4j class library, but seemingly compiled but not easy to use, you have to implement the LINQ API can be.

Java implements LINQ, mainly using static import

For example, implement a group aggregation query for a list. For example, the total amount of recharge according to month statistics

List result = Select (' Month,sum (RECHG) as Total '). from (list). GroupBy ("Month"). by ("Total,desc");

Author:: Nickname: Old Wow's paw (full name:: Attilax Akbar Al Rapanui Attilaksachanui)

Chinese name: Etila (Airon), email:1466519819@qq.com

Reprint please indicate the source: Http://blog.csdn.net/attilax

Atiend

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.