<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Java8 on Aamer Paul</title>
    <link>https://aamernabi.github.io/tags/java8/</link>
    <description>Recent content in Java8 on Aamer Paul</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Tue, 26 Mar 2024 21:25:32 +0530</lastBuildDate>
    <atom:link href="https://aamernabi.github.io/tags/java8/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Understanding Functional Interfaces in Java</title>
      <link>https://aamernabi.github.io/posts/java-functional-interface/</link>
      <pubDate>Tue, 26 Mar 2024 21:25:32 +0530</pubDate>
      <guid>https://aamernabi.github.io/posts/java-functional-interface/</guid>
      <description>&lt;p&gt;A &lt;strong&gt;functional interface&lt;/strong&gt; in Java is an interface that contains exactly one abstract method. Introduced in Java 8, they are the backbone of lambda expressions and the Stream API, enabling a more functional style of programming. They are also known as &lt;strong&gt;Single Abstract Method (SAM)&lt;/strong&gt; interfaces.&lt;/p&gt;&#xA;&lt;p&gt;To ensure an interface is a functional interface, you can use the &lt;code&gt;@FunctionalInterface&lt;/code&gt; annotation. The compiler will then trigger an error if the interface does not meet the requirements.&lt;/p&gt;</description>
    </item>
    <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>
    <item>
      <title>Mastering Asynchronous Programming with Java&#39;s CompletableFuture</title>
      <link>https://aamernabi.github.io/posts/java-completable-future/</link>
      <pubDate>Mon, 27 Jul 2020 12:09:10 +0530</pubDate>
      <guid>https://aamernabi.github.io/posts/java-completable-future/</guid>
      <description>&lt;p&gt;Introduced in Java 8, &lt;code&gt;CompletableFuture&lt;/code&gt; is a powerful class for asynchronous programming. It extends the traditional &lt;code&gt;Future&lt;/code&gt; interface with a rich set of features for composing, combining, and handling asynchronous tasks, enabling you to write non-blocking, highly concurrent applications with ease.&lt;/p&gt;&#xA;&lt;h2 id=&#34;why-completablefuture&#34;&gt;Why &lt;code&gt;CompletableFuture&lt;/code&gt;?&lt;/h2&gt;&#xA;&lt;p&gt;Before &lt;code&gt;CompletableFuture&lt;/code&gt;, Java&amp;rsquo;s &lt;code&gt;Future&lt;/code&gt; was limited. You could start an asynchronous task, but you had to block your main thread using &lt;code&gt;get()&lt;/code&gt; to retrieve the result. This defeated the purpose of non-blocking code.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
