Java Lamda Stream

Source: Internet
Author: User

    • Intermediate: A stream can be followed by 0 or more intermediate operations. The main purpose is to open the stream, make a certain degree of data mapping/filtering, and then return a new stream to be used by the next operation. This type of operation is lazy (lazy), which means that only calls to such a method do not actually begin the traversal of the stream.
    • Terminal: A stream can have only one Terminal operation, and when the operation is executed, the stream is used "light" and cannot be manipulated again. So this must be the last operation of the stream. Terminal the execution of the operation, the traversal of the stream is actually started, and a result is generated, or a side effect.

int sum = Widgets.stream (). Filter (W, w.getcolor () = = RED). Maptoint (W-w.getweight ()). sum ();

  

Stream () gets the Source,filter and maptoint of the current small object for the intermediate operation, for data filtering and conversion, and the last sum () for the terminal operation, which sums up all the small objects that meet the criteria.

    • Intermediate:

Map (Maptoint, FLATMAP, etc.), filter, DISTINCT, sorted, peek, limit, skip, parallel, sequential, unordered

    • Terminal:

ForEach, foreachordered, ToArray, reduce, collect, Min, Max, Count, AnyMatch, Allmatch, Nonematch, FindFirst, Findany, ite Rator

    • Short-circuiting:

AnyMatch, Allmatch, Nonematch, FindFirst, Findany, limit

Java Lamda Stream

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.