<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Streams on Aamer Paul</title>
    <link>https://aamernabi.github.io/tags/streams/</link>
    <description>Recent content in Streams on Aamer Paul</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Mon, 07 Jun 2021 18:12:23 +0530</lastBuildDate>
    <atom:link href="https://aamernabi.github.io/tags/streams/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>A Deep Dive into the Java Stream API</title>
      <link>https://aamernabi.github.io/posts/deep-dive-into-java-stream-api/</link>
      <pubDate>Mon, 07 Jun 2021 18:12:23 +0530</pubDate>
      <guid>https://aamernabi.github.io/posts/deep-dive-into-java-stream-api/</guid>
      <description>&lt;p&gt;The &lt;strong&gt;Stream API&lt;/strong&gt;, introduced in Java 8, is a powerful tool for processing sequences of elements. It provides a functional approach to working with collections and arrays, allowing for expressive and efficient data manipulation. Streams don&amp;rsquo;t store data; instead, they operate on a data source, such as a &lt;code&gt;Collection&lt;/code&gt; or an array, and enable aggregate operations.&lt;/p&gt;&#xA;&lt;h2 id=&#34;core-concepts&#34;&gt;Core Concepts&lt;/h2&gt;&#xA;&lt;p&gt;A stream pipeline consists of three parts:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;A source&lt;/strong&gt;: Where the stream originates from (e.g., a &lt;code&gt;List&lt;/code&gt;, &lt;code&gt;Set&lt;/code&gt;, or array).&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Zero or more intermediate operations&lt;/strong&gt;: These transform the stream into another stream. Examples include &lt;code&gt;filter&lt;/code&gt;, &lt;code&gt;map&lt;/code&gt;, and &lt;code&gt;sorted&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;A terminal operation&lt;/strong&gt;: This produces a result or a side-effect, and triggers the execution of the pipeline. Examples include &lt;code&gt;forEach&lt;/code&gt;, &lt;code&gt;collect&lt;/code&gt;, and &lt;code&gt;reduce&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;One of the key features of streams is &lt;strong&gt;laziness&lt;/strong&gt;. Intermediate operations are not executed until a terminal operation is invoked. This allows the Stream API to optimize the execution of the pipeline.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
